Skip to content

Commit 8a81cf9

Browse files
JuliaLawallrafaeljw
authored andcommitted
thermal/of: add missing of_node_put()
for_each_child_of_node performs an of_node_get on each iteration, so a break out of the loop requires an of_node_put. This was done using the Coccinelle semantic patch iterators/for_each_child.cocci Signed-off-by: Julia Lawall <Julia.Lawall@inria.fr> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent 0bb80ec commit 8a81cf9

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

drivers/thermal/thermal_of.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,10 @@ static int of_find_trip_id(struct device_node *np, struct device_node *trip)
3737
*/
3838
for_each_child_of_node(trips, t) {
3939

40-
if (t == trip)
40+
if (t == trip) {
41+
of_node_put(t);
4142
goto out;
43+
}
4244
i++;
4345
}
4446

@@ -401,8 +403,10 @@ static int thermal_of_for_each_cooling_maps(struct thermal_zone_device *tz,
401403

402404
for_each_child_of_node(cm_np, child) {
403405
ret = thermal_of_for_each_cooling_device(tz_np, child, tz, cdev, action);
404-
if (ret)
406+
if (ret) {
407+
of_node_put(child);
405408
break;
409+
}
406410
}
407411

408412
of_node_put(cm_np);

0 commit comments

Comments
 (0)