Messages in this thread Patch in this message | | | From | Yann Sionneau <> | Subject | [PATCH] net: phylink: check for pcs_ops being NULL | Date | Tue, 21 Jun 2022 15:49:17 +0200 |
| |
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
| |