Netdev List
 help / color / mirror / Atom feed
* [PATCH] net: bgmac: fix refcount leak in bgmac_phy_connect_direct()
@ 2026-06-09  7:44 Wentao Liang
  2026-06-11 14:42 ` Simon Horman
  0 siblings, 1 reply; 2+ messages in thread
From: Wentao Liang @ 2026-06-09  7:44 UTC (permalink / raw)
  To: rafal, bcm-kernel-feedback-list, andrew+netdev, davem, edumazet,
	kuba, pabeni
  Cc: netdev, linux-kernel, Wentao Liang, stable

In bgmac_phy_connect_direct(), fixed_phy_register() returns a
phy_device with an incremented refcount. If the subsequent
phy_connect_direct() call fails, the function returns the error
without releasing the phy_device reference. Add the missing
fixed_phy_unregister() in the error path to prevent the leak.

Cc: stable@vger.kernel.org
Fixes: c25b23b8a387 ("bgmac: register fixed PHY for ARM BCM470X / BCM5301X chipsets")
Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
---
 drivers/net/ethernet/broadcom/bgmac.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/ethernet/broadcom/bgmac.c b/drivers/net/ethernet/broadcom/bgmac.c
index 3e9c57196a39..c97cf7ebad7f 100644
--- a/drivers/net/ethernet/broadcom/bgmac.c
+++ b/drivers/net/ethernet/broadcom/bgmac.c
@@ -1456,6 +1456,7 @@ int bgmac_phy_connect_direct(struct bgmac *bgmac)
 				 PHY_INTERFACE_MODE_MII);
 	if (err) {
 		dev_err(bgmac->dev, "Connecting PHY failed\n");
+		fixed_phy_unregister(phy_dev);
 		return err;
 	}
 
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-06-11 14:44 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-09  7:44 [PATCH] net: bgmac: fix refcount leak in bgmac_phy_connect_direct() Wentao Liang
2026-06-11 14:42 ` Simon Horman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox