drivers: thermal: add check when unregistering cpu cooling
authorEduardo Valentin <eduardo.valentin@ti.com>
Thu, 15 Aug 2013 14:54:46 +0000 (10:54 -0400)
committerAlex Shi <alex.shi@linaro.org>
Fri, 26 Sep 2014 08:45:44 +0000 (16:45 +0800)
This patch avoids NULL pointer accesses while unregistering
cpu cooling devices, in case a NULL pointer is received.

Cc: Zhang Rui <rui.zhang@intel.com>
Cc: linux-pm@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Eduardo Valentin <eduardo.valentin@ti.com>
(cherry picked from commit 50e66c7ed8a1cd7e933628f9f5cf2617394adf5a)
Signed-off-by: Alex Shi <alex.shi@linaro.org>
drivers/thermal/cpu_cooling.c

index 8c1547424502c8af163cab4db689f2aa53930477..4246262c4bd249f5ee0d3cec5f3712d1fdd9bbc6 100644 (file)
@@ -549,8 +549,12 @@ EXPORT_SYMBOL_GPL(of_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--;