net: dsa: mv88e6xxx: Fix refcount leak in mv88e6xxx_mdios_register
Subsystems (4)
PATCH v3 1/1 net: dsa: mv88e6xxx: Fix refcount leak in mv88e6xxx_mdios_register
of_get_child_by_name() returns a node pointer with refcount incremented, we should use of_node_put() on it when done.
mv88e6xxx_mdio_register() pass the device node to of_mdiobus_register(). We don't need the device node after it.
Add missing of_node_put() to avoid refcount leak.
---
changes in v2:
- Add fixes tag.
changes in v3:
- Move of_node_put() statement to cover normal path.
- Update commit message.
I do cross-check to determine we should release the node after of_mdiobus_register(), refer to functions like lan78xx_mdio_init(), ave_init() and ag71xx_mdio_probe().
v1 link: https://lore.kernel.org/r/[email protected]/
v2 link: https://lore.kernel.org/all/[email protected]/
--- drivers/net/dsa/mv88e6xxx/chip.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/dsa/mv88e6xxx/chip.c +1 -0
@@ -3960,6 +3960,7 @@ static int mv88e6xxx_mdios_register(struct mv88e6xxx_chip *chip,*/ child =of_get_child_by_name (np,"mdio" ); err =mv88e6xxx_mdio_register (chip, child, false); +of_node_put (child);if (err)return err;
Signature · 1 line
2.25.1
Quoted 32 lines · On Thu, 26 May 2022 18:52:08 +0400 Miaoqian Lin <[email protected]> wrote:
of_get_child_by_name()returns a node pointer with refcount incremented, we should useof_node_put()on it when done.
mv88e6xxx_mdio_register()pass the device node toof_mdiobus_register(). We don't need the device node after it.Add missing
of_node_put()to avoid refcount leak.Fixes a3c53be55c95 ("net: dsa: mv88e6xxx: Support multiple MDIO busses")Signed-off-by Miaoqian Lin <[email protected]>---
changes in v2:
- Add fixes tag.
changes in v3:
- Moveof_node_put()statement to cover normal path.
- Update commit message.I do cross-check to determine we should release the node after
of_mdiobus_register(), refer to functions likelan78xx_mdio_init(),ave_init()andag71xx_mdio_probe().v1 link: https://lore.kernel.org/r/[email protected]/
v2 link: https://lore.kernel.org/all/[email protected]/--- drivers/net/dsa/mv88e6xxx/chip.c | 1 + 1 file changed, 1 insertion(+)drivers/net/dsa/mv88e6xxx/chip.c +0
-0
drivers/net/dsa/mv88e6xxx/chip.c static int mv88e6xxx_mdios_register(struct mv88e6xxx_chip *chip, · line 3966
Quoted 7 lines
drivers/net/dsa/mv88e6xxx/chip.c +1
-0@@ -3960,6 +3960,7 @@ static int mv88e6xxx_mdios_register(struct mv88e6xxx_chip *chip,*/ child =of_get_child_by_name (np,"mdio" ); err =mv88e6xxx_mdio_register (chip, child, false); +of_node_put (child);if (err)return err;
This patch was applied to netdev/net.git (master) by David S. Miller <[email protected]>:
Hello:
This patch was applied to netdev/net.git (master)
by David S. Miller <[email protected]>:
Quoted 9 lines · On Thu, 26 May 2022 18:52:08 +0400 you wrote:
of_get_child_by_name()returns a node pointer with refcount incremented, we should useof_node_put()on it when done.
mv88e6xxx_mdio_register()pass the device node toof_mdiobus_register(). We don't need the device node after it.Add missing
of_node_put()to avoid refcount leak.[...]
Here is the summary with links:
- [v3] net: dsa: mv88e6xxx: Fix refcount leak in mv88e6xxx_mdios_register
https://git.kernel.org/netdev/net/c/02ded5a17361
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html