Skip to content

Commit c7a5403

Browse files
javiercarrascocruzgregkh
authored andcommitted
usb: core: add missing of_node_put() in usb_of_has_devices_or_graph
The for_each_child_of_node() macro requires an explicit call to of_node_put() on early exits to decrement the child refcount and avoid a memory leak. The child node is not required outsie the loop, and the resource must be released before the function returns. Add the missing of_node_put(). Cc: [email protected] Fixes: 82e8213 ("usb: core: Set connect_type of ports based on DT node") Signed-off-by: Javier Carrasco <[email protected]> Reviewed-by: Stephen Boyd <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 3859e85 commit c7a5403

File tree

1 file changed

+5
-2
lines changed
  • drivers/usb/core

1 file changed

+5
-2
lines changed

drivers/usb/core/of.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,12 @@ static bool usb_of_has_devices_or_graph(const struct usb_device *hub)
8484
if (of_graph_is_present(np))
8585
return true;
8686

87-
for_each_child_of_node(np, child)
88-
if (of_property_present(child, "reg"))
87+
for_each_child_of_node(np, child) {
88+
if (of_property_present(child, "reg")) {
89+
of_node_put(child);
8990
return true;
91+
}
92+
}
9093

9194
return false;
9295
}

0 commit comments

Comments
 (0)