]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
net: rtsn: fix mdio_node leak in rtsn_mdio_alloc()
authorShitalkumar Gandhi <shital.gandhi45@gmail.com>
Tue, 5 May 2026 12:32:36 +0000 (18:02 +0530)
committerJakub Kicinski <kuba@kernel.org>
Thu, 7 May 2026 00:42:50 +0000 (17:42 -0700)
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>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Reviewed-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Link: https://patch.msgid.link/20260505123236.406000-1-shitalkumar.gandhi@cambiumnetworks.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/renesas/rtsn.c

index 03a2669f051879d2bdab210850a61471d88585a8..ee8381b60b8d495012b40eb8c61287ba9e93b8d7 100644 (file)
@@ -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);
@@ -824,6 +824,8 @@ static int rtsn_mdio_alloc(struct rtsn_private *priv)
 
        return 0;
 
+out_put_node:
+       of_node_put(mdio_node);
 out_free_bus:
        mdiobus_free(mii);
        return ret;