]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
thermal: Exynos: Fix NULL pointer dereference in exynos_unregister_thermal()
authorSachin Kamat <sachin.kamat@linaro.org>
Thu, 27 Sep 2012 10:50:38 +0000 (16:20 +0530)
committerZhang Rui <rui.zhang@intel.com>
Fri, 28 Sep 2012 00:22:15 +0000 (08:22 +0800)
exynos_unregister_thermal() is functional only when 'th_zone' is not
NULL (ensured by the NULL checks). However, in the event it is NULL, it
gets dereferenced in the for loop. This patch fixes this issue.

Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
drivers/thermal/exynos_thermal.c

index 4b203b6e06b85d68148003315ec0fe09cd99cc32..4997a3a7936f7a27c39e54f9012a46c86f660950 100644 (file)
@@ -475,11 +475,14 @@ static void exynos_unregister_thermal(void)
 {
        int i;
 
-       if (th_zone && th_zone->therm_dev)
+       if (!th_zone)
+               return;
+
+       if (th_zone->therm_dev)
                thermal_zone_device_unregister(th_zone->therm_dev);
 
        for (i = 0; i < th_zone->cool_dev_size; i++) {
-               if (th_zone && th_zone->cool_dev[i])
+               if (th_zone->cool_dev[i])
                        cpufreq_cooling_unregister(th_zone->cool_dev[i]);
        }