Thread (17 messages) 17 messages, 3 authors, 2021-09-09

[thermal: thermal/next] thermal/core/thermal_of: Stop zone device before unregistering it

From: thermal-bot for Dmitry Osipenko <hidden>
Date: 2021-06-21 09:47:00
Subsystem: the rest, thermal · Maintainers: Linus Torvalds, Rafael J. Wysocki, Daniel Lezcano

The following commit has been merged into the thermal/next branch of thermal:

Commit-ID:     add9a126cfb59375c36e779bf739fc765219ed11
Gitweb:        https://git.kernel.org/pub/scm/linux/kernel/git/thermal/linux.git//add9a126cfb59375c36e779bf739fc765219ed11
Author:        Dmitry Osipenko [off-list ref]
AuthorDate:    Wed, 16 Jun 2021 22:04:13 +03:00
Committer:     Daniel Lezcano [off-list ref]
CommitterDate: Fri, 18 Jun 2021 12:39:50 +02:00

thermal/core/thermal_of: Stop zone device before unregistering it

Zone device is enabled after thermal_zone_of_sensor_register() completion,
but it's not disabled before senor is unregistered, leaving temperature
polling active. This results in accessing a disabled zone device and
produces a warning about this problem. Stop zone device before
unregistering it in order to fix this "use-after-free" problem.

Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
Signed-off-by: Daniel Lezcano <redacted>
Link: https://lore.kernel.org/r/20210616190417.32214-3-digetx@gmail.com (local)
---
 drivers/thermal/thermal_of.c | 3 +++
 1 file changed, 3 insertions(+)
diff --git a/drivers/thermal/thermal_of.c b/drivers/thermal/thermal_of.c
index 5b76f9a..6379f26 100644
--- a/drivers/thermal/thermal_of.c
+++ b/drivers/thermal/thermal_of.c
@@ -559,6 +559,9 @@ void thermal_zone_of_sensor_unregister(struct device *dev,
 	if (!tz)
 		return;
 
+	/* stop temperature polling */
+	thermal_zone_device_disable(tzd);
+
 	mutex_lock(&tzd->lock);
 	tzd->ops->get_temp = NULL;
 	tzd->ops->get_trend = NULL;
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help