Skip to content

Commit d2a3697

Browse files
hkallweitdavem330
authored andcommitted
net: phy: don't allow __set_phy_supported to add unsupported modes
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]>
1 parent 35b827b commit d2a3697

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
@@ -1880,20 +1880,17 @@ EXPORT_SYMBOL(genphy_loopback);
18801880

18811881
static int __set_phy_supported(struct phy_device *phydev, u32 max_speed)
18821882
{
1883-
phydev->supported &= ~(PHY_1000BT_FEATURES | PHY_100BT_FEATURES |
1884-
PHY_10BT_FEATURES);
1885-
18861883
switch (max_speed) {
1887-
default:
1888-
return -ENOTSUPP;
1889-
case SPEED_1000:
1890-
phydev->supported |= PHY_1000BT_FEATURES;
1884+
case SPEED_10:
1885+
phydev->supported &= ~PHY_100BT_FEATURES;
18911886
/* fall through */
18921887
case SPEED_100:
1893-
phydev->supported |= PHY_100BT_FEATURES;
1894-
/* fall through */
1895-
case SPEED_10:
1896-
phydev->supported |= PHY_10BT_FEATURES;
1888+
phydev->supported &= ~PHY_1000BT_FEATURES;
1889+
break;
1890+
case SPEED_1000:
1891+
break;
1892+
default:
1893+
return -ENOTSUPP;
18971894
}
18981895

18991896
return 0;

0 commit comments

Comments
 (0)