Skip to content

Commit ea37bec

Browse files
groeckrafaeljw
authored andcommitted
thermal/core: Protect hwmon accesses to thermal operations with thermal zone mutex
In preparation to protecting access to thermal operations against thermal zone device removal, protect hwmon accesses to thermal zone operations with the thermal zone mutex. After acquiring the mutex, ensure that the thermal zone device is registered before proceeding. Signed-off-by: Guenter Roeck <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent 1c439de commit ea37bec

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

drivers/thermal/thermal_hwmon.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,15 @@ temp_crit_show(struct device *dev, struct device_attribute *attr, char *buf)
7777
int temperature;
7878
int ret;
7979

80-
ret = tz->ops->get_crit_temp(tz, &temperature);
80+
mutex_lock(&tz->lock);
81+
82+
if (device_is_registered(&tz->device))
83+
ret = tz->ops->get_crit_temp(tz, &temperature);
84+
else
85+
ret = -ENODEV;
86+
87+
mutex_unlock(&tz->lock);
88+
8189
if (ret)
8290
return ret;
8391

0 commit comments

Comments
 (0)