Skip to content

Commit d35f29e

Browse files
groeckrafaeljw
authored andcommitted
thermal/core: Destroy thermal zone device mutex in release function
Accesses to thermal zones, and with it the thermal zone device mutex, are still possible after the thermal zone device has been unregistered. For example, thermal_zone_get_temp() can be called from temp_show() in thermal_sysfs.c if the sysfs attribute was opened before the thermal device was unregistered. Move the call to mutex_destroy from thermal_zone_device_unregister() to thermal_release() to ensure that it is only destroyed after it is guaranteed to be no longer accessed. Signed-off-by: Guenter Roeck <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent e49a1e1 commit d35f29e

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/thermal/thermal_core.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -754,6 +754,7 @@ static void thermal_release(struct device *dev)
754754
sizeof("thermal_zone") - 1)) {
755755
tz = to_thermal_zone(dev);
756756
thermal_zone_destroy_device_groups(tz);
757+
mutex_destroy(&tz->lock);
757758
kfree(tz);
758759
} else if (!strncmp(dev_name(dev), "cooling_device",
759760
sizeof("cooling_device") - 1)) {
@@ -1390,7 +1391,6 @@ void thermal_zone_device_unregister(struct thermal_zone_device *tz)
13901391
thermal_remove_hwmon_sysfs(tz);
13911392
ida_free(&thermal_tz_ida, tz->id);
13921393
ida_destroy(&tz->ida);
1393-
mutex_destroy(&tz->lock);
13941394
device_unregister(&tz->device);
13951395

13961396
thermal_notify_tz_delete(tz_id);

0 commit comments

Comments
 (0)