Skip to content

Commit afc954f

Browse files
krzkrafaeljw
authored andcommitted
thermal: of: Fix OF node leak in thermal_of_trips_init() error path
Terminating for_each_child_of_node() loop requires dropping OF node reference, so bailing out after thermal_of_populate_trip() error misses this. Solve the OF node reference leak with scoped for_each_child_of_node_scoped(). Fixes: d0c75fa ("thermal/of: Initialize trip points separately") Cc: All applicable <[email protected]> Signed-off-by: Krzysztof Kozlowski <[email protected]> Reviewed-by: Chen-Yu Tsai <[email protected]> Reviewed-by: Daniel Lezcano <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent 57df60e commit afc954f

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/thermal/thermal_of.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ static int thermal_of_populate_trip(struct device_node *np,
125125
static struct thermal_trip *thermal_of_trips_init(struct device_node *np, int *ntrips)
126126
{
127127
struct thermal_trip *tt;
128-
struct device_node *trips, *trip;
128+
struct device_node *trips;
129129
int ret, count;
130130

131131
trips = of_get_child_by_name(np, "trips");
@@ -150,7 +150,7 @@ static struct thermal_trip *thermal_of_trips_init(struct device_node *np, int *n
150150
*ntrips = count;
151151

152152
count = 0;
153-
for_each_child_of_node(trips, trip) {
153+
for_each_child_of_node_scoped(trips, trip) {
154154
ret = thermal_of_populate_trip(trip, &tt[count++]);
155155
if (ret)
156156
goto out_kfree;

0 commit comments

Comments
 (0)