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

* Re: [PATCH net-next] net: dsa: hellcreek: fix device_node leak in hellcreek_led_setup()
  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
  1 sibling, 1 reply; 4+ messages in thread
From: netdev-bot+sinfo @ 2026-11-06  8:51 UTC (permalink / raw)
  To: Xia Yan
  Cc: netdev, Kurt Kanzenbach, Andrew Lunn, Vladimir Oltean,
	Richard Cochran, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	David S. Miller, Pavel Zhigulin, linux-kernel, yana06070

Hi!

This is an automated message. This series looks like a fix, but its
commit messages seem to be missing some information:

 - Whether the issue was actually triggered, or is only theoretical
   (e.g. found by code inspection). If it was triggered please include
   the symptoms, like the stack trace or error messages.

Please do not repost the series just to address the above. Instead,
reply to this email with the missing information, so that reviewers
can take it into account. If the series needs another revision for
other reasons, please include the information in the commit messages
then.

The evaluation is done by an LLM so it may be wrong, if you think
that is the case please reply and explain.

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

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

On 11/6/26 16:51, netdev-bot+sinfo wrote:
>  - Whether the issue was actually triggered, or is only theoretical
>    (e.g. found by code inspection). If it was triggered please include
>    the symptoms, like the stack trace or error messages.

Hi,

The leak was not hit at runtime. I found it by code inspection while
reviewing the OF node handling in DSA drivers, as the commit message
notes. There is no stack trace: the effect would be one device_node
reference leaked per probe and never released.

Thanks,
Xia Yan



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

* Re: [PATCH net-next] net: dsa: hellcreek: fix device_node leak in hellcreek_led_setup()
  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  9:54 ` Kurt Kanzenbach
  1 sibling, 0 replies; 4+ messages in thread
From: Kurt Kanzenbach @ 2026-11-06  9:54 UTC (permalink / raw)
  To: Xia Yan, netdev
  Cc: Andrew Lunn, Vladimir Oltean, Richard Cochran, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, David S. Miller, Pavel Zhigulin,
	linux-kernel, yana06070

[-- Attachment #1: Type: text/plain, Size: 926 bytes --]

On Fri Nov 06 2026, Xia Yan wrote:
> 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>

Looks correct to me. Thanks.

Reviewed-by: Kurt Kanzenbach <kurt@linutronix.de>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 861 bytes --]

^ 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®