Commit c7a5403e authored by Javier Carrasco's avatar Javier Carrasco Committed by Greg Kroah-Hartman

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: stable@vger.kernel.org
Fixes: 82e82130 ("usb: core: Set connect_type of ports based on DT node")
Signed-off-by: default avatarJavier Carrasco <javier.carrasco.cruz@gmail.com>
Reviewed-by: default avatarStephen Boyd <swboyd@chromium.org>
Link: https://lore.kernel.org/r/20240624-usb_core_of_memleak-v1-1-af6821c1a584@gmail.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 3859e85d
......@@ -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;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment