From: Eduardo Valentin Date: Thu, 15 Aug 2013 14:54:46 +0000 (-0400) Subject: drivers: thermal: add check when unregistering cpu cooling X-Git-Tag: upstream/snapshot3+hdmi~4335^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=50e66c7ed8a1cd7e933628f9f5cf2617394adf5a;p=platform%2Fadaptation%2Frenesas_rcar%2Frenesas_kernel.git drivers: thermal: add check when unregistering cpu cooling 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 --- diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c index 5b3744e..d179028 100644 --- a/drivers/thermal/cpu_cooling.c +++ b/drivers/thermal/cpu_cooling.c @@ -498,8 +498,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--;