Skip to content

Commit

Permalink
thermal/of: add missing of_node_put()
Browse files Browse the repository at this point in the history
[ Upstream commit 8a81cf9 ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
JuliaLawall authored and gregkh committed Oct 6, 2023
1 parent d6a68f1 commit 49bdfc8
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions drivers/thermal/thermal_of.c
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,10 @@ static int of_find_trip_id(struct device_node *np, struct device_node *trip)
*/
for_each_child_of_node(trips, t) {

if (t == trip)
if (t == trip) {
of_node_put(t);
goto out;
}
i++;
}

Expand Down Expand Up @@ -519,8 +521,10 @@ static int thermal_of_for_each_cooling_maps(struct thermal_zone_device *tz,

for_each_child_of_node(cm_np, child) {
ret = thermal_of_for_each_cooling_device(tz_np, child, tz, cdev, action);
if (ret)
if (ret) {
of_node_put(child);
break;
}
}

of_node_put(cm_np);
Expand Down

0 comments on commit 49bdfc8

Please sign in to comment.