Skip to contentSkip to conversation

net: phylink: avoid oops during initialisation

PATCH Applied Russell King 2 participants 2 messages Aug 28, 2020 – Aug 31, 2020

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: phylink: avoid oops during initialisation

If we intend to use PCS operations, mac_pcs_get_state() will not be implemented, so will be NULL. If we also intend to register the PCS operations in mac_prepare() or mac_config(), then this leads to an attempt to call NULL function pointer during phylink_start(). Avoid this, but we must report the link is down.

---
There are no users of the new split PCS support currently, so this does not require backporting, but if people think it should have a fixes tag, that would be:

     Fixes: 7137e18f6f88 ("net: phylink: add struct phylink_pcs")
 drivers/net/phy/phylink.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/phy/phylink.c +3 -1
index 32b4bd6a5b55..5e4cb12972eb 100644
@@ -535,8 +535,10 @@ static void phylink_mac_pcs_get_state(struct phylink *pl,
 
 	if (pl->pcs_ops)
 		pl->pcs_ops->pcs_get_state(pl->pcs, state);
-	else
+	else if (pl->mac_ops->mac_pcs_get_state)
 		pl->mac_ops->mac_pcs_get_state(pl->config, state);
+	else
+		state->link = 0;
 }
 
 /* The fixed state is... fixed except for the link state,
Signature · 1 line
2.20.1
maintainer Applied
#1 lore raw

From: Russell King <[email protected]>
Date: Fri, 28 Aug 2020 11:53:53 +0100

Quoted 7 lines

If we intend to use PCS operations, mac_pcs_get_state() will not be implemented, so will be NULL. If we also intend to register the PCS operations in mac_prepare() or mac_config(), then this leads to an attempt to call NULL function pointer during phylink_start(). Avoid this, but we must report the link is down.

Applied, thank you.