Skip to content

Commit

Permalink
net: sparx5: fix error handling in sparx5_port_open()
Browse files Browse the repository at this point in the history
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: 946e7fd ("net: sparx5: add port module support")
Fixes: f3cad26 ("net: sparx5: add hostmode with phylink support")
Signed-off-by: Liu Jian <[email protected]>
Tested-by: Bjarni Jonasson <[email protected]>
Reviewed-by: Steen Hegelund <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Abeni <[email protected]>
  • Loading branch information
liujian56 authored and Paolo Abeni committed Nov 22, 2022
1 parent aad98ab commit 4305fe2
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions drivers/net/ethernet/microchip/sparx5/sparx5_netdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,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);
Expand All @@ -116,10 +116,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;
}

Expand Down

0 comments on commit 4305fe2

Please sign in to comment.