[PATCH net-next 1/4] net: ethernet: validate pause autoneg setting

Doug Berger
2020-05-12T00:25:00Z

A comment in uapi/linux/ethtool.h states "Drivers should reject a
non-zero setting of @autoneg when autoneogotiation is disabled (or
not supported) for the link".

That check should be added to phy_validate_pause() to consolidate
the code where possible.

Fixes: 22b7d29926b5 ("net: ethernet: Add helper to determine if pause configuration is supported")
Signed-off-by: Doug Berger <opendmb@gmail.com>
---
drivers/net/phy/phy_device.c | 3 +++
1 file changed, 3 insertions(+)

diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index c3a107cf578e..5a9618ba232e 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -2624,6 +2624,9 @@ EXPORT_SYMBOL(phy_set_asym_pause);
bool phy_validate_pause(struct phy_device *phydev,
struct ethtool_pauseparam *pp)
{
+ if (pp->autoneg && !phydev->autoneg)
+ return false;
+
if (!linkmode_test_bit(ETHTOOL_LINK_MODE_Pause_BIT,
phydev->supported) && pp->rx_pause)
return false;
--
2.7.4