linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net: phylink: check for pcs_ops being NULL
@ 2022-06-21 13:49 Yann Sionneau
  2022-06-21 16:01 ` Russell King (Oracle)
  0 siblings, 1 reply; 2+ messages in thread
From: Yann Sionneau @ 2022-06-21 13:49 UTC (permalink / raw)
  To: linux-kernel
  Cc: Russell King, Andrew Lunn, Heiner Kallweit, David S . Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, netdev, jvetter,
	jmaselbas, Yann Sionneau

Out of tree drivers that have not been updated
after 001f4261fe4d ("net: phylink: use legacy_pre_march2020") would not set the
legacy_pre_march2020 boolean which if not initialized will default to false.
Such drivers will most likely still be using the legacy interface and will
not have pcs_ops.

Check for pcs_ops being NULL even if driver does not advertise itself
as "pre march 2020 legacy". This commit adds a simple check instead of
dereferencing a NULL pointer and prints an error message to indicate
that the driver needs to be updated.

Signed-off-by: Yann Sionneau <ysionneau@kalray.eu>
---
 drivers/net/phy/phylink.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c
index 06943889d747..94abf418afb1 100644
--- a/drivers/net/phy/phylink.c
+++ b/drivers/net/phy/phylink.c
@@ -874,6 +874,14 @@ static int phylink_change_inband_advert(struct phylink *pl)
 		return 0;
 	}
 
+	if (unlikely(!pl->pcs_ops)) {
+		phylink_err(pl, "%s: Error, net driver needs to either be "
+			    "updated to use pcs_ops or actually advertise it "
+			    "has legacy interface by setting "
+			    "legacy_pre_march2020 boolean", __func__);
+		return -EINVAL;
+	}
+
 	phylink_dbg(pl, "%s: mode=%s/%s adv=%*pb pause=%02x\n", __func__,
 		    phylink_an_mode_str(pl->cur_link_an_mode),
 		    phy_modes(pl->link_config.interface),
-- 
2.17.1


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

* Re: [PATCH] net: phylink: check for pcs_ops being NULL
  2022-06-21 13:49 [PATCH] net: phylink: check for pcs_ops being NULL Yann Sionneau
@ 2022-06-21 16:01 ` Russell King (Oracle)
  0 siblings, 0 replies; 2+ messages in thread
From: Russell King (Oracle) @ 2022-06-21 16:01 UTC (permalink / raw)
  To: Yann Sionneau
  Cc: linux-kernel, Andrew Lunn, Heiner Kallweit, David S . Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, netdev, jvetter,
	jmaselbas

On Tue, Jun 21, 2022 at 03:49:17PM +0200, Yann Sionneau wrote:
> Out of tree drivers that have not been updated
> after 001f4261fe4d ("net: phylink: use legacy_pre_march2020") would not set the
> legacy_pre_march2020 boolean which if not initialized will default to false.
> Such drivers will most likely still be using the legacy interface and will
> not have pcs_ops.

... which means they're broken. The answer is not to patch phylink like
this, because even with this, it's likely that they are still broken.

They need to set legacy_pre_march2020.

Note that the legacy stuff will be going away - some of it, such as the
mac_pcs_an_restart() method will be going away, maybe in the next merge
window.

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!

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

end of thread, other threads:[~2022-06-21 16:02 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-21 13:49 [PATCH] net: phylink: check for pcs_ops being NULL Yann Sionneau
2022-06-21 16:01 ` Russell King (Oracle)

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).