mirror of
https://github.com/torvalds/linux.git
synced 2026-11-07 06:17:02 +01:00
net: phy: call driver remove when core initialization fails
phy_probe() may fail while querying features or completing other core initialization after the PHY driver probe callback has succeeded. The driver core does not run the remove path after a probe error, so resources that the PHY driver releases in its remove callback are leaked. Call the PHY driver remove callback on these failures. Reviewed-by: Andrew Lunn <andrew@lunn.ch> Signed-off-by: Xuanqiang Luo <luoxuanqiang@kylinos.cn> Link: https://patch.msgid.link/20260823035600.188864-5-xuanqiang.luo@linux.dev Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
parent
52dd7eb1a3
commit
afd5aecd3c
|
|
@ -3758,7 +3758,7 @@ static int phy_probe(struct device *dev)
|
|||
err = genphy_read_abilities(phydev);
|
||||
|
||||
if (err)
|
||||
goto out_reset;
|
||||
goto out_remove;
|
||||
|
||||
if (!linkmode_test_bit(ETHTOOL_LINK_MODE_Autoneg_BIT,
|
||||
phydev->supported))
|
||||
|
|
@ -3775,7 +3775,7 @@ static int phy_probe(struct device *dev)
|
|||
|
||||
err = phy_setup_ports(phydev);
|
||||
if (err)
|
||||
goto out_reset;
|
||||
goto out_remove;
|
||||
|
||||
phy_advertise_supported(phydev);
|
||||
|
||||
|
|
@ -3850,6 +3850,10 @@ static int phy_probe(struct device *dev)
|
|||
phy_sfp_release(phydev);
|
||||
phy_cleanup_ports(phydev);
|
||||
|
||||
out_remove:
|
||||
if (phydev->drv->remove)
|
||||
phydev->drv->remove(phydev);
|
||||
|
||||
out_reset:
|
||||
/* Re-assert the reset signal on error */
|
||||
phy_device_reset(phydev, 1);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user