* [PATCH] net: hisilicon: hns_dsaf_mac: fix mdio device leak in hns_mac_register_phy()
@ 2026-09-17 11:08 Wentao Liang
2026-09-21 10:27 ` Simon Horman
2026-09-22 11:20 ` patchwork-bot+netdevbpf
0 siblings, 2 replies; 3+ messages in thread
From: Wentao Liang @ 2026-09-17 11:08 UTC (permalink / raw)
To: Yisen.Zhuang
Cc: andrew+netdev, davem, edumazet, kuba, linux-kernel, netdev,
pabeni, shenjian15, yankejian, Wentao Liang, stable
hns_dsaf_find_platform_device() returns the mdio platform device with its
reference count incremented. hns_mac_register_phy() never drops that
reference, so the mdio device can not be released.
Release the reference on both the deferred probe and the normal path.
Fixes: 1d1afa2ebf82 ("net: hns: register phy device in each mac initial sequence")
Cc: stable@vger.kernel.org
Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
---
drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c
index bc6b269be299..f1cb6d56e4b9 100644
--- a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c
+++ b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c
@@ -793,6 +793,7 @@ static int hns_mac_register_phy(struct hns_mac_cb *mac_cb)
dev_err(mac_cb->dev,
"mac%d mdio is NULL, dsaf will probe again later\n",
mac_cb->mac_id);
+ put_device(&pdev->dev);
return -EPROBE_DEFER;
}
@@ -801,6 +802,8 @@ static int hns_mac_register_phy(struct hns_mac_cb *mac_cb)
dev_dbg(mac_cb->dev, "mac%d register phy addr:%d\n",
mac_cb->mac_id, addr);
+ put_device(&pdev->dev);
+
return rc;
}
--
2.34.1
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] net: hisilicon: hns_dsaf_mac: fix mdio device leak in hns_mac_register_phy()
2026-09-17 11:08 [PATCH] net: hisilicon: hns_dsaf_mac: fix mdio device leak in hns_mac_register_phy() Wentao Liang
@ 2026-09-21 10:27 ` Simon Horman
2026-09-22 11:20 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: Simon Horman @ 2026-09-21 10:27 UTC (permalink / raw)
To: Wentao Liang
Cc: Yisen.Zhuang, andrew+netdev, davem, edumazet, kuba, linux-kernel,
netdev, pabeni, shenjian15, yankejian, stable
On Thu, Sep 17, 2026 at 11:08:28AM +0000, Wentao Liang wrote:
> hns_dsaf_find_platform_device() returns the mdio platform device with its
> reference count incremented. hns_mac_register_phy() never drops that
> reference, so the mdio device can not be released.
>
> Release the reference on both the deferred probe and the normal path.
>
> Fixes: 1d1afa2ebf82 ("net: hns: register phy device in each mac initial sequence")
> Cc: stable@vger.kernel.org
> Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
Reviewed-by: Simon Horman <horms@kernel.org>
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] net: hisilicon: hns_dsaf_mac: fix mdio device leak in hns_mac_register_phy()
2026-09-17 11:08 [PATCH] net: hisilicon: hns_dsaf_mac: fix mdio device leak in hns_mac_register_phy() Wentao Liang
2026-09-21 10:27 ` Simon Horman
@ 2026-09-22 11:20 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-09-22 11:20 UTC (permalink / raw)
To: Wentao Liang
Cc: Yisen.Zhuang, andrew+netdev, davem, edumazet, kuba, linux-kernel,
netdev, pabeni, shenjian15, yankejian, stable
Hello:
This patch was applied to netdev/net.git (main)
by Paolo Abeni <pabeni@redhat.com>:
On Thu, 17 Sep 2026 11:08:28 +0000 you wrote:
> hns_dsaf_find_platform_device() returns the mdio platform device with its
> reference count incremented. hns_mac_register_phy() never drops that
> reference, so the mdio device can not be released.
>
> Release the reference on both the deferred probe and the normal path.
>
> Fixes: 1d1afa2ebf82 ("net: hns: register phy device in each mac initial sequence")
> Cc: stable@vger.kernel.org
> Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
>
> [...]
Here is the summary with links:
- net: hisilicon: hns_dsaf_mac: fix mdio device leak in hns_mac_register_phy()
https://git.kernel.org/netdev/net/c/999e8295bc41
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] 3+ messages in thread
end of thread, other threads:[~2026-09-22 11:21 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-17 11:08 [PATCH] net: hisilicon: hns_dsaf_mac: fix mdio device leak in hns_mac_register_phy() Wentao Liang
2026-09-21 10:27 ` Simon Horman
2026-09-22 11:20 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®