* [PATCH net] net: netsec: fix error handling in netsec_register_mdio()
@ 2022-10-19 6:41 Yang Yingliang
2022-10-21 5:10 ` patchwork-bot+netdevbpf
0 siblings, 1 reply; 2+ messages in thread
From: Yang Yingliang @ 2022-10-19 6:41 UTC (permalink / raw)
To: netdev; +Cc: ard.biesheuvel, jaswinder.singh, davem
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.
Fixes: 533dd11a12f6 ("net: socionext: Add Synquacer NetSec driver")
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
---
drivers/net/ethernet/socionext/netsec.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/net/ethernet/socionext/netsec.c b/drivers/net/ethernet/socionext/netsec.c
index 2240f6d0b89b..9b46579b5a10 100644
--- a/drivers/net/ethernet/socionext/netsec.c
+++ b/drivers/net/ethernet/socionext/netsec.c
@@ -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);
--
2.25.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH net] net: netsec: fix error handling in netsec_register_mdio()
2022-10-19 6:41 [PATCH net] net: netsec: fix error handling in netsec_register_mdio() Yang Yingliang
@ 2022-10-21 5:10 ` patchwork-bot+netdevbpf
0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-10-21 5:10 UTC (permalink / raw)
To: Yang Yingliang; +Cc: netdev, ard.biesheuvel, jaswinder.singh, davem
Hello:
This patch was applied to netdev/net.git (master)
by Jakub Kicinski <kuba@kernel.org>:
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 in mdiobus_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!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-10-21 5:11 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-19 6:41 [PATCH net] net: netsec: fix error handling in netsec_register_mdio() Yang Yingliang
2022-10-21 5:10 ` patchwork-bot+netdevbpf
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.