Skip to content

Commit e44c8cb

Browse files
hkallweitgregkh
authored andcommitted
net: phy: don't allow __set_phy_supported to add unsupported modes
[ Upstream commit d2a3697 ] 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: f3a6bd3 ("phylib: Add phy_set_max_speed helper") Signed-off-by: Heiner Kallweit <[email protected]> Reviewed-by: Andrew Lunn <[email protected]> Signed-off-by: David S. Miller <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 583e170 commit e44c8cb

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

drivers/net/phy/phy_device.c

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1703,20 +1703,17 @@ EXPORT_SYMBOL(genphy_loopback);
17031703

17041704
static int __set_phy_supported(struct phy_device *phydev, u32 max_speed)
17051705
{
1706-
phydev->supported &= ~(PHY_1000BT_FEATURES | PHY_100BT_FEATURES |
1707-
PHY_10BT_FEATURES);
1708-
17091706
switch (max_speed) {
1710-
default:
1711-
return -ENOTSUPP;
1712-
case SPEED_1000:
1713-
phydev->supported |= PHY_1000BT_FEATURES;
1707+
case SPEED_10:
1708+
phydev->supported &= ~PHY_100BT_FEATURES;
17141709
/* fall through */
17151710
case SPEED_100:
1716-
phydev->supported |= PHY_100BT_FEATURES;
1717-
/* fall through */
1718-
case SPEED_10:
1719-
phydev->supported |= PHY_10BT_FEATURES;
1711+
phydev->supported &= ~PHY_1000BT_FEATURES;
1712+
break;
1713+
case SPEED_1000:
1714+
break;
1715+
default:
1716+
return -ENOTSUPP;
17201717
}
17211718

17221719
return 0;

0 commit comments

Comments
 (0)