[PATCH] thermal: Exynos: Fix NULL pointer dereference in exynos_unregister_thermal()

2012-09-27 Thread Sachin Kamat
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 
---
 drivers/thermal/exynos_thermal.c |7 +--
 1 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/thermal/exynos_thermal.c b/drivers/thermal/exynos_thermal.c
index 4b203b6..4997a3a 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]);
}
 
-- 
1.7.4.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] thermal: Exynos: Fix NULL pointer dereference in exynos_unregister_thermal()

2012-09-27 Thread Sachin Kamat
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.ka...@linaro.org
---
 drivers/thermal/exynos_thermal.c |7 +--
 1 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/thermal/exynos_thermal.c b/drivers/thermal/exynos_thermal.c
index 4b203b6..4997a3a 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]);
}
 
-- 
1.7.4.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/