netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] net: phylink: avoid oops during initialisation
@ 2020-08-28 10:53 Russell King
  2020-08-31 19:23 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Russell King @ 2020-08-28 10:53 UTC (permalink / raw)
  To: Andrew Lunn, Florian Fainelli, Heiner Kallweit
  Cc: David S. Miller, netdev, Jakub Kicinski

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.

Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
---
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(-)

diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c
index 32b4bd6a5b55..5e4cb12972eb 100644
--- a/drivers/net/phy/phylink.c
+++ b/drivers/net/phy/phylink.c
@@ -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,
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH net-next] net: phylink: avoid oops during initialisation
  2020-08-28 10:53 [PATCH net-next] net: phylink: avoid oops during initialisation Russell King
@ 2020-08-31 19:23 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2020-08-31 19:23 UTC (permalink / raw)
  To: rmk+kernel; +Cc: andrew, f.fainelli, hkallweit1, netdev, kuba

From: Russell King <rmk+kernel@armlinux.org.uk>
Date: Fri, 28 Aug 2020 11:53:53 +0100

> 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.
> 
> Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>

Applied, thank you.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-08-31 19:23 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-28 10:53 [PATCH net-next] net: phylink: avoid oops during initialisation Russell King
2020-08-31 19:23 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).