aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/thermal/thermal_sys.c
diff options
context:
space:
mode:
authorHugh Dickins <hughd@google.com>2012-09-27 19:48:28 -0400
committerZhang Rui <rui.zhang@intel.com>2012-11-05 01:00:10 -0500
commit791700cdfc2453eb927ff7875d183d9808d89bfb (patch)
tree3a15ca2ea9f3b0094e42f3f329ab54105e2f61f4 /drivers/thermal/thermal_sys.c
parenta56757af8e7d7d8bfb6317c25b6a8809abfceb9a (diff)
Thermal: Fix oops and unlocking in thermal_sys.c
This patch fixes the following mutex and NULL pointer problems in thermal_sys.c: * mutex_unlock fix in update_temperature function * mutex_unlock fix in bind_cdev function * Correct early return to continue in bind_cdev function * NULL check fix in bind_cdev function * NULL check fix in bind_tz function Reported-by: Dan Carpenter <dan.carpenter@oracle.com> Reported-by: Sedat Dilek <sedat.dilek@gmail.com> Reported-by: Hugh Dickins <hughd@google.com> Signed-off-by: Durgadoss R <durgadoss.r@intel.com> Signed-off-by: Sedat Dilek <sedat.dilek@gmail.com> Signed-off-by: Hugh Dickins <hughd@google.com> Signed-off-by: Zhang Rui <rui.zhang@intel.com>
Diffstat (limited to 'drivers/thermal/thermal_sys.c')
-rw-r--r--drivers/thermal/thermal_sys.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/drivers/thermal/thermal_sys.c b/drivers/thermal/thermal_sys.c
index a69f24c4414a..8f0f37bb2825 100644
--- a/drivers/thermal/thermal_sys.c
+++ b/drivers/thermal/thermal_sys.c
@@ -252,8 +252,8 @@ static void bind_cdev(struct thermal_cooling_device *cdev)
252 } 252 }
253 253
254 tzp = pos->tzp; 254 tzp = pos->tzp;
255 if (!tzp->tbp) 255 if (!tzp || !tzp->tbp)
256 return; 256 continue;
257 257
258 for (i = 0; i < tzp->num_tbps; i++) { 258 for (i = 0; i < tzp->num_tbps; i++) {
259 if (tzp->tbp[i].cdev || !tzp->tbp[i].match) 259 if (tzp->tbp[i].cdev || !tzp->tbp[i].match)
@@ -289,7 +289,7 @@ static void bind_tz(struct thermal_zone_device *tz)
289 goto exit; 289 goto exit;
290 } 290 }
291 291
292 if (!tzp->tbp) 292 if (!tzp || !tzp->tbp)
293 goto exit; 293 goto exit;
294 294
295 list_for_each_entry(pos, &thermal_cdev_list, node) { 295 list_for_each_entry(pos, &thermal_cdev_list, node) {
@@ -387,12 +387,13 @@ static void update_temperature(struct thermal_zone_device *tz)
387 ret = tz->ops->get_temp(tz, &temp); 387 ret = tz->ops->get_temp(tz, &temp);
388 if (ret) { 388 if (ret) {
389 pr_warn("failed to read out thermal zone %d\n", tz->id); 389 pr_warn("failed to read out thermal zone %d\n", tz->id);
390 return; 390 goto exit;
391 } 391 }
392 392
393 tz->last_temperature = tz->temperature; 393 tz->last_temperature = tz->temperature;
394 tz->temperature = temp; 394 tz->temperature = temp;
395 395
396exit:
396 mutex_unlock(&tz->lock); 397 mutex_unlock(&tz->lock);
397} 398}
398 399