diff options
author | Serge Semin <fancer.lancer@gmail.com> | 2024-02-22 20:58:23 +0300 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2024-02-26 13:09:09 +0000 |
commit | 361dd531a11bc2c63c3c906a202a9c8a7675f3e7 (patch) | |
tree | cf60851b8796017258da09d7ab4f1e33e529227e /drivers/net/pcs | |
parent | f5151005d379d9ce42e327fd3b2d2aaef61cda81 (diff) | |
download | linux-stable-361dd531a11bc2c63c3c906a202a9c8a7675f3e7.tar.gz linux-stable-361dd531a11bc2c63c3c906a202a9c8a7675f3e7.tar.bz2 linux-stable-361dd531a11bc2c63c3c906a202a9c8a7675f3e7.zip |
net: pcs: xpcs: Explicitly return error on caps validation
If an unsupported interface is passed to the PCS validation callback there
is no need in further link-modes calculations since the resultant array
will be initialized with zeros which will be perceived by the phylink
subsystem as error anyway (see phylink_validate_mac_and_pcs()). Instead
let's explicitly return the -EINVAL error to inform the caller about the
unsupported interface as it's done in the rest of the pcs_validate
callbacks.
Signed-off-by: Serge Semin <fancer.lancer@gmail.com>
Reviewed-by: Maxime Chevallier <maxime.chevallier@bootlin.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/pcs')
-rw-r--r-- | drivers/net/pcs/pcs-xpcs.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/drivers/net/pcs/pcs-xpcs.c b/drivers/net/pcs/pcs-xpcs.c index 02262af336c4..31525fe9c32e 100644 --- a/drivers/net/pcs/pcs-xpcs.c +++ b/drivers/net/pcs/pcs-xpcs.c @@ -613,14 +613,15 @@ static int xpcs_validate(struct phylink_pcs *pcs, unsigned long *supported, xpcs = phylink_pcs_to_xpcs(pcs); compat = xpcs_find_compat(xpcs->id, state->interface); + if (!compat) + return -EINVAL; /* Populate the supported link modes for this PHY interface type. * FIXME: what about the port modes and autoneg bit? This masks * all those away. */ - if (compat) - for (i = 0; compat->supported[i] != __ETHTOOL_LINK_MODE_MASK_NBITS; i++) - set_bit(compat->supported[i], xpcs_supported); + for (i = 0; compat->supported[i] != __ETHTOOL_LINK_MODE_MASK_NBITS; i++) + set_bit(compat->supported[i], xpcs_supported); linkmode_and(supported, supported, xpcs_supported); |