From: Sachin Kamat Date: Thu, 27 Sep 2012 10:50:38 +0000 (+0530) Subject: thermal: Exynos: Fix NULL pointer dereference in exynos_unregister_thermal() X-Git-Tag: next-20121001~75^2~3 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=f224ce9934831857a8bfb0915c36a4f994ae76ea;p=karo-tx-linux.git thermal: Exynos: Fix NULL pointer dereference in exynos_unregister_thermal() 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 --- diff --git a/drivers/thermal/exynos_thermal.c b/drivers/thermal/exynos_thermal.c index 4b203b6e06b8..4997a3a7936f 100644 --- a/drivers/thermal/exynos_thermal.c +++ b/drivers/thermal/exynos_thermal.c @@ -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]); }