net: sparx5: fix error handling in sparx5_port_open()
[ Upstream commit4305fe232b
] If phylink_of_phy_connect() fails, the port should be disabled. If sparx5_serdes_set()/phy_power_on() fails, the port should be disabled and the phylink should be stopped and disconnected. Fixes:946e7fd505
("net: sparx5: add port module support") Fixes:f3cad2611a
("net: sparx5: add hostmode with phylink support") Signed-off-by: Liu Jian <liujian56@huawei.com> Tested-by: Bjarni Jonasson <bjarni.jonasson@microchip.com> Reviewed-by: Steen Hegelund <steen.hegelund@microchip.com> Link: https://lore.kernel.org/r/20221117125918.203997-1-liujian56@huawei.com Signed-off-by: Paolo Abeni <pabeni@redhat.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
Родитель
182ef20f0f
Коммит
a05c0f9511
|
@ -83,7 +83,7 @@ static int sparx5_port_open(struct net_device *ndev)
|
|||
err = phylink_of_phy_connect(port->phylink, port->of_node, 0);
|
||||
if (err) {
|
||||
netdev_err(ndev, "Could not attach to PHY\n");
|
||||
return err;
|
||||
goto err_connect;
|
||||
}
|
||||
|
||||
phylink_start(port->phylink);
|
||||
|
@ -95,10 +95,20 @@ static int sparx5_port_open(struct net_device *ndev)
|
|||
err = sparx5_serdes_set(port->sparx5, port, &port->conf);
|
||||
else
|
||||
err = phy_power_on(port->serdes);
|
||||
if (err)
|
||||
if (err) {
|
||||
netdev_err(ndev, "%s failed\n", __func__);
|
||||
goto out_power;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
out_power:
|
||||
phylink_stop(port->phylink);
|
||||
phylink_disconnect_phy(port->phylink);
|
||||
err_connect:
|
||||
sparx5_port_enable(port, false);
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче