From: Keerthy Subject: Re: [PATCH] thermal: ti-soc-thermal: Fix ti_thermal_unregister_cpu_cooling NULL pointer on unload Date: Wed, 18 Oct 2017 09:19:49 +0530 Message-ID: <63050967-7665-b655-8c9e-5e72b19c2cbe@ti.com> References: <20171016210714.16080-1-tony@atomide.com> Mime-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <20171016210714.16080-1-tony@atomide.com> Content-Language: en-US Sender: linux-pm-owner@vger.kernel.org To: Tony Lindgren , Eduardo Valentin , Zhang Rui Cc: linux-pm@vger.kernel.org, linux-omap@vger.kernel.org List-Id: linux-omap@vger.kernel.org On Tuesday 17 October 2017 02:37 AM, Tony Lindgren wrote: > 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) Acked-by: Keerthy > > Cc: Keerthy > Signed-off-by: Tony Lindgren > --- > drivers/thermal/ti-soc-thermal/ti-thermal-common.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/drivers/thermal/ti-soc-thermal/ti-thermal-common.c b/drivers/thermal/ti-soc-thermal/ti-thermal-common.c > --- 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; >