[PATCH AUTOSEL 4.19 057/146] net: phy: phylink: ensure the carrier is off when starting phylink

From: Sasha Levin
Date: Wed Oct 31 2018 - 19:50:10 EST

From: Antoine Tenart <antoine.tenart@xxxxxxxxxxx>

[ Upstream commit aeeb2e8fdefdd5d257a1446351c70cb3df540199 ]

Phylink made an assumption about the carrier state being down when
calling phylink_start(). If this assumption isn't satisfied, the
internal phylink state could misbehave and a net device could end up not
being functional.

This patch fixes this by explicitly calling netif_carrier_off() in

Signed-off-by: Antoine Tenart <antoine.tenart@xxxxxxxxxxx>
Acked-by: Russell King <rmk+kernel@xxxxxxxxxxxxxxx>
Signed-off-by: David S. Miller <davem@xxxxxxxxxxxxx>
Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>
drivers/net/phy/phylink.c | 3 +++
1 file changed, 3 insertions(+)

diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c
index 7abca86c3aa9..70f3f90c2ed6 100644
--- a/drivers/net/phy/phylink.c
+++ b/drivers/net/phy/phylink.c
@@ -907,6 +907,9 @@ void phylink_start(struct phylink *pl)

+ /* Always set the carrier off */
+ netif_carrier_off(pl->netdev);
/* Apply the link configuration to the MAC when starting. This allows
* a fixed-link to start with the correct parameters, and also
* ensures that we set the appropriate advertisement for Serdes links.