Commit 4f384d94 authored by Heiner Kallweit's avatar Heiner Kallweit Committed by Greg Kroah-Hartman

net: phy: don't allow __set_phy_supported to add unsupported modes

[ Upstream commit d2a36971ef595069b7a600d1144c2e0881a930a1 ]

Currently __set_phy_supported allows to add modes w/o checking whether
the PHY supports them. This is wrong, it should never add modes but
only remove modes we don't want to support.

The commit marked as fixed didn't do anything wrong, it just copied
existing functionality to the helper which is being fixed now.

Fixes: f3a6bd39 ("phylib: Add phy_set_max_speed helper")
Signed-off-by: default avatarHeiner Kallweit <hkallweit1@gmail.com>
Reviewed-by: default avatarAndrew Lunn <andrew@lunn.ch>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 5765610c
...@@ -1579,20 +1579,17 @@ static int gen10g_resume(struct phy_device *phydev) ...@@ -1579,20 +1579,17 @@ static int gen10g_resume(struct phy_device *phydev)
static int __set_phy_supported(struct phy_device *phydev, u32 max_speed) static int __set_phy_supported(struct phy_device *phydev, u32 max_speed)
{ {
phydev->supported &= ~(PHY_1000BT_FEATURES | PHY_100BT_FEATURES |
PHY_10BT_FEATURES);
switch (max_speed) { switch (max_speed) {
default: case SPEED_10:
return -ENOTSUPP; phydev->supported &= ~PHY_100BT_FEATURES;
case SPEED_1000:
phydev->supported |= PHY_1000BT_FEATURES;
/* fall through */ /* fall through */
case SPEED_100: case SPEED_100:
phydev->supported |= PHY_100BT_FEATURES; phydev->supported &= ~PHY_1000BT_FEATURES;
/* fall through */ break;
case SPEED_10: case SPEED_1000:
phydev->supported |= PHY_10BT_FEATURES; break;
default:
return -ENOTSUPP;
} }
return 0; return 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment