lkml.org 
[lkml]   [2026]   [May]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH net] net: rtsn: fix mdio_node leak in rtsn_mdio_alloc()
Hi Shitalkumar,

On Mon, 4 May 2026 at 22:05, Shitalkumar Gandhi
<shital.gandhi45@gmail.com> wrote:
> of_get_child_by_name() takes a reference. The rtsn_reset() and
> rtsn_change_mode() failure paths jump to out_free_bus and leak
> mdio_node.
>
> Add out_put_node to drop it before falling through.
>
> Fixes: b0d3969d2b4d ("net: ethernet: rtsn: Add support for Renesas Ethernet-TSN")
> Signed-off-by: Shitalkumar Gandhi <shitalkumar.gandhi@cambiumnetworks.com>

Thanks for your patch!

> --- a/drivers/net/ethernet/renesas/rtsn.c
> +++ b/drivers/net/ethernet/renesas/rtsn.c
> @@ -797,11 +797,11 @@ static int rtsn_mdio_alloc(struct rtsn_private *priv)
> /* Enter config mode before registering the MDIO bus */
> ret = rtsn_reset(priv);
> if (ret)
> - goto out_free_bus;
> + goto out_put_node;
>
> ret = rtsn_change_mode(priv, OCR_OPC_CONFIG);
> if (ret)
> - goto out_free_bus;
> + goto out_put_node;
>
> rtsn_modify(priv, MPIC, MPIC_PSMCS_MASK | MPIC_PSMHT_MASK,
> MPIC_PSMCS_DEFAULT | MPIC_PSMHT_DEFAULT);
> @@ -823,7 +823,8 @@ static int rtsn_mdio_alloc(struct rtsn_private *priv)
> priv->mii = mii;
>
> return 0;
> -

Please keep this blank line, as it serves as a clear separation between
success and failure paths.

> +out_put_node:
> + of_node_put(mdio_node);
> out_free_bus:
> mdiobus_free(mii);
> return ret;

For the logical change:
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

\
 
 \ /
  Last update: 2026-05-05 09:45    [W:0.074 / U:11.412 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and my Meterkast|Read the blog