mirror of
https://github.com/torvalds/linux.git
synced 2026-11-07 06:17:02 +01:00
net: phy: propagate errors from default port setup
phy_default_setup_single_port() ignores errors from phy_add_port() and always reports success. If a PHY driver attach_mdi_port() callback fails, the phy_port is leaked and PHY probing continues without the expected default port. Destroy the port and return the error. Reviewed-by: Maxime Chevallier <maxime.chevallier@bootlin.com> Signed-off-by: Xuanqiang Luo <luoxuanqiang@kylinos.cn> Link: https://patch.msgid.link/20260823035600.188864-6-xuanqiang.luo@linux.dev Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
parent
afd5aecd3c
commit
48378efebb
|
|
@ -3483,6 +3483,7 @@ static int phy_default_setup_single_port(struct phy_device *phydev)
|
|||
{
|
||||
struct phy_port *port = phy_port_alloc();
|
||||
unsigned long mode;
|
||||
int ret;
|
||||
|
||||
if (!port)
|
||||
return -ENOMEM;
|
||||
|
|
@ -3509,9 +3510,11 @@ static int phy_default_setup_single_port(struct phy_device *phydev)
|
|||
port->pairs = max_t(int, port->pairs,
|
||||
ethtool_linkmode_n_pairs(mode));
|
||||
|
||||
phy_add_port(phydev, port);
|
||||
ret = phy_add_port(phydev, port);
|
||||
if (ret)
|
||||
phy_port_destroy(port);
|
||||
|
||||
return 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int of_phy_ports(struct phy_device *phydev)
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user