Skip to content

Commit 4f384d9

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 5765610 commit 4f384d9

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
@@ -1579,20 +1579,17 @@ static int gen10g_resume(struct phy_device *phydev)
15791579

15801580
static int __set_phy_supported(struct phy_device *phydev, u32 max_speed)
15811581
{
1582-
phydev->supported &= ~(PHY_1000BT_FEATURES | PHY_100BT_FEATURES |
1583-
PHY_10BT_FEATURES);
1584-
15851582
switch (max_speed) {
1586-
default:
1587-
return -ENOTSUPP;
1588-
case SPEED_1000:
1589-
phydev->supported |= PHY_1000BT_FEATURES;
1583+
case SPEED_10:
1584+
phydev->supported &= ~PHY_100BT_FEATURES;
15901585
/* fall through */
15911586
case SPEED_100:
1592-
phydev->supported |= PHY_100BT_FEATURES;
1593-
/* fall through */
1594-
case SPEED_10:
1595-
phydev->supported |= PHY_10BT_FEATURES;
1587+
phydev->supported &= ~PHY_1000BT_FEATURES;
1588+
break;
1589+
case SPEED_1000:
1590+
break;
1591+
default:
1592+
return -ENOTSUPP;
15961593
}
15971594

15981595
return 0;

0 commit comments

Comments
 (0)