net: xgene: fix mdio_np leak in xgene_mdiobus_register()
PATCH 1/1 net: xgene: fix mdio_np leak in xgene_mdiobus_register()
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.
--- drivers/net/ethernet/apm/xgene/xgene_enet_hw.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/ethernet/apm/xgene/xgene_enet_hw.c +3 -1
@@ -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. */
Signature · 1 line
2.25.1
This patch was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:
Quoted 10 lines · On Thu, 7 May 2026 19:50:24 +0530 you wrote:
The
for_each_child_of_node()loop capturesmdio_npvia 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 <[email protected]>[...]
Here is the summary with links:
- [net] net: xgene: fix mdio_np leak in xgene_mdiobus_register()
https://git.kernel.org/netdev/net/c/a450063ef86b
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html
Quoted 8 lines · Shitalkumar Gandhi
The
for_each_child_of_node()loop capturesmdio_npvia 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 <[email protected]>
FTR: There is an AI-generated review of this patch which you may
want to look at for possible follow-up. I do not believe it should block progress of this patch.
Simon Horman
reviewerQuoted 7 lines · Simon Horman
Quoted 6 lines · Shitalkumar Gandhi
The
for_each_child_of_node()loop capturesmdio_npvia break, holding the refcount.of_mdiobus_register()does not consume the reference, so it leaks on success.Put it after registration.
Quoted 8 lines
Quoted 2 lines
Fixes e6ad767305eb ("drivers: net: Add APM X-Gene SoC ethernet driver support.")Signed-off-by Shitalkumar Gandhi <[email protected]>Reviewed-by Simon Horman <[email protected]>FTR: There is an AI-generated review of this patch which you may
want to look at for possible follow-up. I do not believe it should block progress of this patch.
I meant to mention that the AI-generated review I'm referring to is available on sashiko.dev.