Netdev List
 help / color / mirror / Atom feed
* [PATCH v2] net: ethernet: ti: netcp_core: fix device_node refcount leak in netcp_probe()
@ 2026-08-14 19:04 manushprajwal
  2026-08-14 20:06 ` Andrew Lunn
  0 siblings, 1 reply; 2+ messages in thread
From: manushprajwal @ 2026-08-14 19:04 UTC (permalink / raw)
  To: davem
  Cc: Andrew Lunn, Eric Dumazet, Jakub Kicinski, Paolo Abeni, netdev,
	Manush Prajwal

From: Manush Prajwal <manushprajwal555@gmail.com>

When netcp_create_interface() failed for a given child node,
netcp_probe() jumped to probe_quit_interface, which released the
"interfaces" parent node but never the "child" node that the
for_each_available_child_of_node() loop was iterating on.

Rework the loop around for_each_available_child_of_node_scoped()
instead of adding a manual of_node_put(). child is only read inside
the loop body and is never used after it, so the scoped macro's
automatic cleanup on the goto is sufficient on its own.

Signed-off-by: Manush Prajwal <manushprajwal555@gmail.com>
---
v2: Rework using for_each_available_child_of_node_scoped() instead of
    a manual of_node_put(), per Andrew Lunn's review.

 drivers/net/ethernet/ti/netcp_core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/ti/netcp_core.c b/drivers/net/ethernet/ti/netcp_core.c
index eb8fc2ed05..a888aa35fa 100644
--- a/drivers/net/ethernet/ti/netcp_core.c
+++ b/drivers/net/ethernet/ti/netcp_core.c
@@ -2204,7 +2204,7 @@ static int netcp_probe(struct platform_device *pdev)
 {
 	struct device_node *node = pdev->dev.of_node;
 	struct netcp_intf *netcp_intf, *netcp_tmp;
-	struct device_node *child, *interfaces;
+	struct device_node *interfaces;
 	struct netcp_device *netcp_device;
 	struct device *dev = &pdev->dev;
 	struct netcp_module *module;
@@ -2246,7 +2246,7 @@ static int netcp_probe(struct platform_device *pdev)
 		goto probe_quit;
 	}

-	for_each_available_child_of_node(interfaces, child) {
+	for_each_available_child_of_node_scoped(interfaces, child) {
 		ret = netcp_create_interface(netcp_device, child);
 		if (ret) {
 			dev_err(dev, "could not create interface(%pOFn)\n",
--
2.46.2.windows.1

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-08-14 20:06 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-14 19:04 [PATCH v2] net: ethernet: ti: netcp_core: fix device_node refcount leak in netcp_probe() manushprajwal
2026-08-14 20:06 ` Andrew Lunn

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox