Skip to contentSkip to conversation

net: dsa: microchip: lan937x: fix reference count leak in lan937x_mdio_register()

PATCH Applied Sun Ke 3 participants 3 messages Sep 8, 2022 – Sep 19, 2022

Subsystems (5)
lore
Share & tools
lore

Sun Ke

author
#0 lore raw

PATCH 1/1 net: dsa: microchip: lan937x: fix reference count leak in lan937x_mdio_register()

This node pointer is returned by of_find_compatible_node() with refcount incremented in this function. of_node_put() on it before exitting this function.

Fixes c9cd961c0d43 ("net: dsa: microchip: lan937x: add interrupt support for port phy link")
---
 drivers/net/dsa/microchip/lan937x_main.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/dsa/microchip/lan937x_main.c +3 -1
index 4867aa62dd4c..18ff0b6a92cc 100644
@@ -238,8 +238,10 @@ static int lan937x_mdio_register(struct ksz_device *dev)
 	ds->slave_mii_bus = bus;
 
 	ret = lan937x_irq_phy_setup(dev);
-	if (ret)
+	if (ret) {
+		of_node_put(mdio_np);
 		return ret;
+	}
 
 	ret = devm_of_mdiobus_register(ds->dev, bus, mdio_np);
 	if (ret) {
Signature · 1 line
2.31.1
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · Sun Ke

This node pointer is returned by of_find_compatible_node() with refcount incremented in this function. of_node_put() on it before exitting this function.

Fixes c9cd961c0d43 ("net: dsa: microchip: lan937x: add interrupt support for port phy link")

Andrew

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

Hello:

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

Quoted 8 lines · On Thu, 8 Sep 2022 12:02:26 +0800 you wrote:

This node pointer is returned by of_find_compatible_node() with refcount incremented in this function. of_node_put() on it before exitting this function.

Fixes c9cd961c0d43 ("net: dsa: microchip: lan937x: add interrupt support for port phy link")

[...]

Here is the summary with links:
- net: dsa: microchip: lan937x: fix reference count leak in lan937x_mdio_register()

    https://git.kernel.org/netdev/net-next/c/2f8a786f4724

You are awesome, thank you!

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