mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH net-next] net: dsa: hellcreek: fix device_node leak in hellcreek_led_setup()
@ 2026-11-06  8:48 Xia Yan
  2026-11-06  8:51 ` netdev-bot+sinfo
  2026-11-06  9:54 ` Kurt Kanzenbach
  0 siblings, 2 replies; 4+ messages in thread
From: Xia Yan @ 2026-11-06  8:48 UTC (permalink / raw)
  To: netdev
  Cc: Kurt Kanzenbach, Andrew Lunn, Vladimir Oltean, Richard Cochran,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, David S. Miller,
	Pavel Zhigulin, linux-kernel, yana06070

hellcreek_led_setup() walks the two LED child nodes of the "leds" node
with of_get_next_available_child(). The helper drops the reference on
the child passed to it and takes one on the child it returns. After
the second call the caller holds a reference on the second LED node.

That reference is never dropped. The out: label only releases the
"leds" node itself. Boards with both LED child nodes leak one
device_node reference per probe, on the registration failures as well
as on the success path.

Drop it at the out: label, before the parent node. The early exits,
where the walk stopped before the second child, pass NULL, which
of_node_put() ignores.

Found during a code review of the OF node handling in DSA drivers.

Signed-off-by: Xia Yan <yanxia@cmss.chinamobile.com>
---
  drivers/net/dsa/hirschmann/hellcreek_ptp.c | 1 +
  1 file changed, 1 insertion(+)
diff --git a/drivers/net/dsa/hirschmann/hellcreek_ptp.c b/drivers/net/dsa/hirschmann/hellcreek_ptp.c
index cb23bea9c21b..ed27731d4f4e 100644
--- a/drivers/net/dsa/hirschmann/hellcreek_ptp.c
+++ b/drivers/net/dsa/hirschmann/hellcreek_ptp.c
@@ -392,6 +392,7 @@ static int hellcreek_led_setup(struct hellcreek *hellcreek)
 	ret = 0;
 
 out:
+	of_node_put(led);
 	of_node_put(leds);
 
 	return ret;



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

end of thread, other threads:[~2026-11-06  9:54 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-06  8:48 [PATCH net-next] net: dsa: hellcreek: fix device_node leak in hellcreek_led_setup() Xia Yan
2026-11-06  8:51 ` netdev-bot+sinfo
2026-11-06  8:59   ` Xia Yan
2026-11-06  9:54 ` Kurt Kanzenbach

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

all inboxes | Powered by JetHome®