summaryrefslogtreecommitdiffstats
path: root/drivers/thermal
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/thermal')
-rw-r--r--drivers/thermal/thermal_core.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
index b31d32476672..5d19dc6a82b4 100644
--- a/drivers/thermal/thermal_core.c
+++ b/drivers/thermal/thermal_core.c
@@ -1391,7 +1391,12 @@ void thermal_zone_device_unregister(struct thermal_zone_device *tz)
thermal_remove_hwmon_sysfs(tz);
ida_free(&thermal_tz_ida, tz->id);
ida_destroy(&tz->ida);
- device_unregister(&tz->device);
+
+ mutex_lock(&tz->lock);
+ device_del(&tz->device);
+ mutex_unlock(&tz->lock);
+
+ put_device(&tz->device);
thermal_notify_tz_delete(tz_id);
}