From patchwork Mon Oct 16 21:07:14 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tony Lindgren X-Patchwork-Id: 10009891 X-Patchwork-Delegate: eduardo.valentin@ti.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id D13E8604D7 for ; Mon, 16 Oct 2017 21:07:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C3EFA286CB for ; Mon, 16 Oct 2017 21:07:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B84AB286DA; Mon, 16 Oct 2017 21:07:22 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 484B5286D4 for ; Mon, 16 Oct 2017 21:07:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757579AbdJPVHV (ORCPT ); Mon, 16 Oct 2017 17:07:21 -0400 Received: from muru.com ([72.249.23.125]:44620 "EHLO muru.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757515AbdJPVHU (ORCPT ); Mon, 16 Oct 2017 17:07:20 -0400 Received: from sampyla.muru.com (localhost [127.0.0.1]) by muru.com (Postfix) with ESMTP id 26F7D8196; Mon, 16 Oct 2017 21:08:36 +0000 (UTC) From: Tony Lindgren To: Eduardo Valentin , Zhang Rui Cc: linux-pm@vger.kernel.org, linux-omap@vger.kernel.org, Keerthy Subject: [PATCH] thermal: ti-soc-thermal: Fix ti_thermal_unregister_cpu_cooling NULL pointer on unload Date: Mon, 16 Oct 2017 14:07:14 -0700 Message-Id: <20171016210714.16080-1-tony@atomide.com> X-Mailer: git-send-email 2.14.2 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Acked-by: Keerthy --- 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;