From ba817a8cfc2e128b59af7fe8b6af72ed38763b87 Mon Sep 17 00:00:00 2001 From: Tony Lindgren Date: Mon, 16 Oct 2017 14:07:14 -0700 Subject: thermal: ti-soc-thermal: Fix ti_thermal_unregister_cpu_cooling NULL pointer on unload While debugging some PM issues and trying to remove all the loaded modules, I ran across the following when unloading ti-soc-thermal: Unable to handle kernel NULL pointer dereference at virtual address 000000b4 ... [] (kobject_put) from [] (ti_thermal_unregister_cpu_cooling+0x20/0x28 [ti_soc_thermal]) [] (ti_thermal_unregister_cpu_cooling [ti_soc_thermal]) from [] (ti_bandgap_remove+0x3c/0x104 [ti_soc_thermal]) [] (ti_bandgap_remove [ti_soc_thermal]) from [] (platform_drv_remove+0x24/0x3c) [] (platform_drv_remove) from [] (device_release_driver_internal+0x160/0x208) [] (device_release_driver_internal) from [] (driver_detach+0x38/0x6c) [] (driver_detach) from [] (bus_remove_driver+0x4c/0xa0) [] (bus_remove_driver) from [] (SyS_delete_module+0x168/0x238) [] (SyS_delete_module) from [] (ret_fast_syscall+0x0/0x28) Cc: Keerthy Signed-off-by: Tony Lindgren Signed-off-by: Eduardo Valentin --- drivers/thermal/ti-soc-thermal/ti-thermal-common.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/thermal/ti-soc-thermal/ti-thermal-common.c b/drivers/thermal/ti-soc-thermal/ti-thermal-common.c index c211a8e4a210..b4f981daeaf2 100644 --- a/drivers/thermal/ti-soc-thermal/ti-thermal-common.c +++ b/drivers/thermal/ti-soc-thermal/ti-thermal-common.c @@ -278,7 +278,8 @@ int ti_thermal_unregister_cpu_cooling(struct ti_bandgap *bgp, int id) if (data) { cpufreq_cooling_unregister(data->cool_dev); - cpufreq_cpu_put(data->policy); + if (data->policy) + cpufreq_cpu_put(data->policy); } return 0; -- cgit v1.2.3-59-g8ed1b