Skip to content

Commit 9f75465

Browse files
gaurijhangianigroeck
authored andcommitted
hwmon: (ina3221) Add of_node_put() before return
Each iteration of for_each_child_of_node puts the previous node, but in the case of a return from the middle of the loop, there is no put, thus causing a memory leak. Hence add an of_node_put before the return. Issue found with Coccinelle. Signed-off-by: Nishka Dasgupta <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Guenter Roeck <[email protected]>
1 parent 277c628 commit 9f75465

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

drivers/hwmon/ina3221.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -713,8 +713,10 @@ static int ina3221_probe_from_dt(struct device *dev, struct ina3221_data *ina)
713713

714714
for_each_child_of_node(np, child) {
715715
ret = ina3221_probe_child_from_dt(dev, child, ina);
716-
if (ret)
716+
if (ret) {
717+
of_node_put(child);
717718
return ret;
719+
}
718720
}
719721

720722
return 0;

0 commit comments

Comments
 (0)