Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932204Ab3HWWD7 (ORCPT ); Fri, 23 Aug 2013 18:03:59 -0400 Received: from devils.ext.ti.com ([198.47.26.153]:32912 "EHLO devils.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932179Ab3HWWD5 (ORCPT ); Fri, 23 Aug 2013 18:03:57 -0400 From: Eduardo Valentin To: , CC: , Eduardo Valentin Subject: [PATCH 5/5] drivers: thermal: add check when unregistering cpu cooling Date: Fri, 23 Aug 2013 18:03:16 -0400 Message-ID: <1377295396-17289-6-git-send-email-eduardo.valentin@ti.com> X-Mailer: git-send-email 1.8.2.1.342.gfa7285d In-Reply-To: <1377295396-17289-1-git-send-email-eduardo.valentin@ti.com> References: <1377295396-17289-1-git-send-email-eduardo.valentin@ti.com> MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1190 Lines: 37 This patch avoids NULL pointer accesses while unregistering cpu cooling devices, in case a NULL pointer is received. Cc: Zhang Rui Cc: linux-pm@vger.kernel.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Eduardo Valentin --- drivers/thermal/cpu_cooling.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c index 82e15db..429a98c 100644 --- a/drivers/thermal/cpu_cooling.c +++ b/drivers/thermal/cpu_cooling.c @@ -496,8 +496,12 @@ EXPORT_SYMBOL_GPL(cpufreq_cooling_register); */ void cpufreq_cooling_unregister(struct thermal_cooling_device *cdev) { - struct cpufreq_cooling_device *cpufreq_dev = cdev->devdata; + struct cpufreq_cooling_device *cpufreq_dev; + if (!cdev) + return; + + cpufreq_dev = cdev->devdata; mutex_lock(&cooling_cpufreq_lock); cpufreq_dev_count--; -- 1.8.2.1.342.gfa7285d -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/