Re: [PATCH net-next] net: dsa: hellcreek: fix device_node leak in hellcreek_led_setup()
From: Kurt Kanzenbach
Date: Fri Nov 06 2026 - 05:03:40 EST
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@xxxxxxxxxxxxxxxxxxxx>
Looks correct to me. Thanks.
Reviewed-by: Kurt Kanzenbach <kurt@xxxxxxxxxxxxx>
Attachment:
signature.asc
Description: PGP signature