Commit 791700cd authored by Hugh Dickins's avatar Hugh Dickins Committed by Zhang Rui

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: default avatarDan Carpenter <>
Reported-by: default avatarSedat Dilek <>
Reported-by: default avatarHugh Dickins <>
Signed-off-by: default avatarDurgadoss R <>
Signed-off-by: default avatarSedat Dilek <>
Signed-off-by: default avatarHugh Dickins <>
Signed-off-by: default avatarZhang Rui <>
parent a56757af
......@@ -252,8 +252,8 @@ static void bind_cdev(struct thermal_cooling_device *cdev)
tzp = pos->tzp;
if (!tzp->tbp)
if (!tzp || !tzp->tbp)
for (i = 0; i < tzp->num_tbps; i++) {
if (tzp->tbp[i].cdev || !tzp->tbp[i].match)
......@@ -289,7 +289,7 @@ static void bind_tz(struct thermal_zone_device *tz)
goto exit;
if (!tzp->tbp)
if (!tzp || !tzp->tbp)
goto exit;
list_for_each_entry(pos, &thermal_cdev_list, node) {
......@@ -387,12 +387,13 @@ static void update_temperature(struct thermal_zone_device *tz)
ret = tz->ops->get_temp(tz, &temp);
if (ret) {
pr_warn("failed to read out thermal zone %d\n", tz->id);
goto exit;
tz->last_temperature = tz->temperature;
tz->temperature = temp;
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment