Skip to content

Commit 811ba48

Browse files
gaurijhangianibroonie
authored andcommitted
regulator: of: Add of_node_put() before return in function
The local variable search in regulator_of_get_init_node takes the value returned by either of_get_child_by_name or of_node_get, both of which get a node. If this node is not put before returning, it could cause a memory leak. Hence put search before a mid-loop return statement. Issue found with Coccinelle. Signed-off-by: Nishka Dasgupta <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent a853c0a commit 811ba48

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

drivers/regulator/of_regulator.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -416,8 +416,10 @@ device_node *regulator_of_get_init_node(struct device *dev,
416416
if (!name)
417417
name = child->name;
418418

419-
if (!strcmp(desc->of_match, name))
419+
if (!strcmp(desc->of_match, name)) {
420+
of_node_put(search);
420421
return of_node_get(child);
422+
}
421423
}
422424

423425
of_node_put(search);

0 commit comments

Comments
 (0)