net: netsec: fix error handling in netsec_register_mdio()
Subsystems (3)
PATCH 1/1 net: netsec: fix error handling in netsec_register_mdio()
If phy_device_register() fails, phy_device_free() need be called to put refcount, so memory of phy device and device name can be freed in callback function.
If get_phy_device() fails, mdiobus_unregister() need be called, or it will cause warning in mdiobus_free() and kobject is leaked.
--- drivers/net/ethernet/socionext/netsec.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/ethernet/socionext/netsec.c +2 -0
@@ -1961,11 +1961,13 @@ static int netsec_register_mdio(struct netsec_priv *priv, u32 phy_addr) ret =PTR_ERR (priv->phydev);dev_err (priv->dev,"get_phy_device err(%d)\n" , ret); priv->phydev =NULL ; +mdiobus_unregister (bus);return -ENODEV ; } ret =phy_device_register (priv->phydev);if (ret) { +phy_device_free (priv->phydev);mdiobus_unregister (bus);dev_err (priv->dev,"phy_device_register err(%d)\n" , ret);
Signature · 1 line
2.25.1
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 Wed, 19 Oct 2022 14:41:04 +0800 you wrote:
If
phy_device_register()fails,phy_device_free()need be called to put refcount, so memory of phy device and device name can be freed in callback function.If
get_phy_device()fails,mdiobus_unregister()need be called, or it will cause warning inmdiobus_free()and kobject is leaked.[...]
Here is the summary with links:
- [net] net: netsec: fix error handling in netsec_register_mdio()
https://git.kernel.org/netdev/net/c/944235896891
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html