瀏覽代碼

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 <sachin.kamat@linaro.org>
Sachin Kamat 13 年之前
父節點
當前提交
c072fed95c
共有 1 個文件被更改,包括 5 次插入2 次删除
  1. 5 2
      drivers/thermal/exynos_thermal.c

+ 5 - 2
drivers/thermal/exynos_thermal.c

@@ -475,11 +475,14 @@ static void exynos_unregister_thermal(void)
 {
 {
 	int i;
 	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);
 		thermal_zone_device_unregister(th_zone->therm_dev);
 
 
 	for (i = 0; i < th_zone->cool_dev_size; i++) {
 	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]);
 			cpufreq_cooling_unregister(th_zone->cool_dev[i]);
 	}
 	}