]> Git Repo - J-linux.git/commitdiff
usb: core: add missing of_node_put() in usb_of_has_devices_or_graph
authorJavier Carrasco <[email protected]>
Mon, 24 Jun 2024 21:10:06 +0000 (23:10 +0200)
committerGreg Kroah-Hartman <[email protected]>
Wed, 3 Jul 2024 14:04:10 +0000 (16:04 +0200)
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: 82e82130a78b ("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]>
drivers/usb/core/of.c

index f1a499ee482c3e9afb0eba256e4401ef33df1390..763e4122ed5b3c2ae3ec37bb1d3c2e67968c8125 100644 (file)
@@ -84,9 +84,12 @@ static bool usb_of_has_devices_or_graph(const struct usb_device *hub)
        if (of_graph_is_present(np))
                return true;
 
-       for_each_child_of_node(np, child)
-               if (of_property_present(child, "reg"))
+       for_each_child_of_node(np, child) {
+               if (of_property_present(child, "reg")) {
+                       of_node_put(child);
                        return true;
+               }
+       }
 
        return false;
 }
This page took 0.048716 seconds and 4 git commands to generate.