]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
net: xgene: fix mdio_np leak in xgene_mdiobus_register()
authorShitalkumar Gandhi <shital.gandhi45@gmail.com>
Thu, 7 May 2026 14:20:24 +0000 (19:50 +0530)
committerJakub Kicinski <kuba@kernel.org>
Sun, 10 May 2026 17:16:58 +0000 (10:16 -0700)
The for_each_child_of_node() loop captures mdio_np via break,
holding the refcount. of_mdiobus_register() does not consume the
reference, so it leaks on success.

Put it after registration.

Fixes: e6ad767305eb ("drivers: net: Add APM X-Gene SoC ethernet driver support.")
Signed-off-by: Shitalkumar Gandhi <shitalkumar.gandhi@cambiumnetworks.com>
Link: https://patch.msgid.link/20260507142024.811543-1-shitalkumar.gandhi@cambiumnetworks.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/apm/xgene/xgene_enet_hw.c

index b854b6b42d77b968405d2db954fec39a8fad4cb5..2926e1e599419de34afe54eb04f09a4f35885692 100644 (file)
@@ -910,7 +910,9 @@ static int xgene_mdiobus_register(struct xgene_enet_pdata *pdata,
                        return -ENXIO;
                }
 
-               return of_mdiobus_register(mdio, mdio_np);
+               ret = of_mdiobus_register(mdio, mdio_np);
+               of_node_put(mdio_np);
+               return ret;
        }
 
        /* Mask out all PHYs from auto probing. */