Skip to contentSkip to conversation

net: ethernet: bgmac: Fix refcount leak in bcma_mdio_mii_register

PATCH Applied Miaoqian Lin 3 participants 3 messages Jun 3, 2022 – Jun 6, 2022

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 net: ethernet: bgmac: Fix refcount leak in bcma_mdio_mii_register

of_get_child_by_name() returns a node pointer with refcount incremented, we should use of_node_put() on it when not need anymore. Add missing of_node_put() to avoid refcount leak.

Fixes 55954f3bfdac ("net: ethernet: bgmac: move BCMA MDIO Phy code into a separate file")

---
changes in v2:
- update Fixes tag.
v1 Link: https://lore.kernel.org/r/[email protected]

---
 drivers/net/ethernet/broadcom/bgmac-bcma-mdio.c | 1 +
 1 file changed, 1 insertion(+)
drivers/net/ethernet/broadcom/bgmac-bcma-mdio.c +1 -0
index 086739e4f40a..9b83d5361699 100644
@@ -234,6 +234,7 @@ struct mii_bus *bcma_mdio_mii_register(struct bgmac *bgmac)
 	np = of_get_child_by_name(core->dev.of_node, "mdio");
 
 	err = of_mdiobus_register(mii_bus, np);
+	of_node_put(np);
 	if (err) {
 		dev_err(&core->dev, "Registration of mii bus failed\n");
 		goto err_free_bus;
Signature · 1 line
2.25.1
Reviewed-by on v2 1/1
#1 lore raw
Quoted 6 lines · Miaoqian Lin

of_get_child_by_name() returns a node pointer with refcount incremented, we should use of_node_put() on it when not need anymore. Add missing of_node_put() to avoid refcount leak.

Fixes 55954f3bfdac ("net: ethernet: bgmac: move BCMA MDIO Phy code into a separate file")

Andrew

#2 lore raw
In reply to Miaoqian Lin
This patch was applied to netdev/net.git (master) by Jakub Kicinski <[email protected]>:

Hello:

This patch was applied to netdev/net.git (master)
by Jakub Kicinski <[email protected]>:

Quoted 8 lines · On Fri, 3 Jun 2022 17:32:38 +0400 you wrote:

of_get_child_by_name() returns a node pointer with refcount incremented, we should use of_node_put() on it when not need anymore. Add missing of_node_put() to avoid refcount leak.

Fixes 55954f3bfdac ("net: ethernet: bgmac: move BCMA MDIO Phy code into a separate file")

[...]

Here is the summary with links:
- [v2] net: ethernet: bgmac: Fix refcount leak in bcma_mdio_mii_register

    https://git.kernel.org/netdev/net/c/b8d91399775c

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html