[PATCH] thermal: thermal_of: fix OF node leak in thermal_of_for_each_cooling_device()
From: zhaofeng2
Date: Fri Nov 27 2026 - 02:42:36 EST
From: Zhao Feng <zhaofeng2@xxxxxxxxxxxxxxxxxxxx>
thermal_of_for_each_cooling_device() calls of_parse_phandle()
to obtain tr_np, uses it only to call of_find_trip_id(), and
then leaks it on every subsequent return path.
Drop the reference with of_node_put() once the node is no
longer needed.
Signed-off-by: Zhao Feng <zhaofeng2@xxxxxxxxxxxxxxxxxxxx>
---
Verified against current tree. Leak found by code inspection
(OF reference-counting audit of thermal_of_for_each_cooling_device()).
thermal/thermal_of.c | 1 +-++
1 file changed, 1 insertion(+), 0 deletion(-)
--- a/drivers/thermal/thermal_of.c
+++ b/drivers/thermal/thermal_of.c
@@ -365,6 +365,7 @@
return -ENODEV;
trip_id = of_find_trip_id(tz_np, tr_np);
+ of_node_put(tr_np);
if (trip_id < 0)
return trip_id;