linux/drivers/firmware/arm_scmi
Sudeep Holla 6ed6c55823 firmware: arm_scmi: Fix NULL pointer dereference in mailbox_chan_free
scmi_mailbox is obtained from cinfo->transport_info and the first
call to mailbox_chan_free frees the channel and sets cinfo->transport_info
to NULL. Care is taken to check for non NULL smbox->chan but smbox can
itself be NULL. Fix it by checking for it without which, kernel crashes
with below NULL pointer dereference and eventually kernel panic.

   Unable to handle kernel NULL pointer dereference at
   		virtual address 0000000000000038
   Modules linked in: scmi_module(-)
   Hardware name: ARM LTD ARM Juno Development Platform/ARM Juno
   		Development Platform, BIOS EDK II Sep  2 2020
   pstate: 80000005 (Nzcv daif -PAN -UAO BTYPE=--)
   pc : mailbox_chan_free+0x2c/0x70 [scmi_module]
   lr : idr_for_each+0x6c/0xf8
   Call trace:
    mailbox_chan_free+0x2c/0x70 [scmi_module]
    idr_for_each+0x6c/0xf8
    scmi_remove+0xa8/0xf0 [scmi_module]
    platform_drv_remove+0x34/0x58
    device_release_driver_internal+0x118/0x1f0
    driver_detach+0x58/0xe8
    bus_remove_driver+0x64/0xe0
    driver_unregister+0x38/0x68
    platform_driver_unregister+0x1c/0x28
    scmi_driver_exit+0x38/0x44 [scmi_module]
   ---[ end trace 17bde19f50436de9 ]---
   Kernel panic - not syncing: Fatal exception
   SMP: stopping secondary CPUs
   Kernel Offset: 0x1d0000 from 0xffff800010000000
   PHYS_OFFSET: 0x80000000
   CPU features: 0x0240022,25806004
   Memory Limit: none
   ---[ end Kernel panic - not syncing: Fatal exception ]---

Link: https://lore.kernel.org/r/20200908112611.31515-1-sudeep.holla@arm.com
Fixes: 5c8a47a5a9 ("firmware: arm_scmi: Make scmi core independent of the transport type")
Cc: Cristian Marussi <cristian.marussi@arm.com>
Cc: Viresh Kumar <viresh.kumar@linaro.org>
Tested-by: Cristian Marussi <cristian.marussi@arm.com>
Reviewed-by: Cristian Marussi <cristian.marussi@arm.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
2020-09-09 10:01:21 +01:00
..
base.c firmware: arm_scmi: Remove fixed size fields from reports/scmi_event_header 2020-07-13 09:40:21 +01:00
bus.c firmware: arm_scmi: Skip protocol initialisation for additional devices 2019-12-24 11:36:26 +00:00
clock.c firmware: arm_scmi: Constify static scmi-ops 2020-09-07 12:43:27 +01:00
common.h firmware: arm_scmi: Constify static scmi-ops 2020-09-07 12:43:27 +01:00
driver.c firmware: arm_scmi: Add SCMI device for system power protocol 2020-09-08 16:02:17 +01:00
mailbox.c firmware: arm_scmi: Fix NULL pointer dereference in mailbox_chan_free 2020-09-09 10:01:21 +01:00
Makefile firmware: arm_scmi: Add system power protocol support 2020-09-08 16:00:55 +01:00
notify.c firmware: arm_scmi: Constify static scmi-ops 2020-09-07 12:43:27 +01:00
notify.h firmware: arm_scmi: Remove fixed size fields from reports/scmi_event_header 2020-07-13 09:40:21 +01:00
perf.c firmware: arm_scmi: Constify static scmi-ops 2020-09-07 12:43:27 +01:00
power.c firmware: arm_scmi: Constify static scmi-ops 2020-09-07 12:43:27 +01:00
reset.c firmware: arm_scmi: Constify static scmi-ops 2020-09-07 12:43:27 +01:00
scmi_pm_domain.c firmware: arm_scmi: Fix SCMI genpd domain probing 2020-06-30 14:08:18 +01:00
sensors.c firmware: arm_scmi: Constify static scmi-ops 2020-09-07 12:43:27 +01:00
shmem.c firmware: arm_scmi: Rename .clear_notification() transport_ops 2020-04-20 17:25:26 +01:00
smc.c firmware: arm_scmi: Constify static scmi-ops 2020-09-07 12:43:27 +01:00
system.c firmware: arm_scmi: Add system power protocol support 2020-09-08 16:00:55 +01:00