Skip to content

Commit 30b2ae0

Browse files
groeckrafaeljw
authored andcommitted
thermal/core: Delete device under thermal device zone lock
Thermal device attributes may still be opened after unregistering the thermal zone and deleting the thermal device. Currently there is no protection against accessing thermal device operations after unregistering a thermal zone. To enable adding such protection, protect the device delete operation with the thermal zone device mutex. This requires splitting the call to device_unregister() into its components, device_del() and put_device(). Only the first call can be executed under mutex protection, since put_device() may result in releasing the thermal zone device memory. Signed-off-by: Guenter Roeck <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent d35f29e commit 30b2ae0

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

drivers/thermal/thermal_core.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1391,7 +1391,12 @@ void thermal_zone_device_unregister(struct thermal_zone_device *tz)
13911391
thermal_remove_hwmon_sysfs(tz);
13921392
ida_free(&thermal_tz_ida, tz->id);
13931393
ida_destroy(&tz->ida);
1394-
device_unregister(&tz->device);
1394+
1395+
mutex_lock(&tz->lock);
1396+
device_del(&tz->device);
1397+
mutex_unlock(&tz->lock);
1398+
1399+
put_device(&tz->device);
13951400

13961401
thermal_notify_tz_delete(tz_id);
13971402
}

0 commit comments

Comments
 (0)