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 --- 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