summaryrefslogtreecommitdiffstats
path: root/drivers/net/phy
diff options
context:
space:
mode:
authorRussell King <rmk+kernel@armlinux.org.uk>2020-08-28 11:53:53 +0100
committerDavid S. Miller <davem@davemloft.net>2020-08-31 12:23:16 -0700
commite859a60add1dd3f844c94c7a782c1a16610bd192 (patch)
treebb718c235372164857750051ad3c79835423537d /drivers/net/phy
parent3b44c793603c78037357a1eee5fe16aad0ac6d72 (diff)
downloadlinux-e859a60add1dd3f844c94c7a782c1a16610bd192.tar.bz2
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. Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/phy')
-rw-r--r--drivers/net/phy/phylink.c4
1 files changed, 3 insertions, 1 deletions
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,