Skip to content

Commit

Permalink
thermal: Exynos: Fix NULL pointer dereference in exynos_unregister_th…
Browse files Browse the repository at this point in the history
…ermal()

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>
  • Loading branch information
Sachin Kamat authored and Zhang Rui committed Sep 28, 2012
1 parent a4b6fec commit c072fed
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions drivers/thermal/exynos_thermal.c
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
}

Expand Down

0 comments on commit c072fed

Please sign in to comment.