Skip to content

Commit c10a485

Browse files
lunndavem330
authored andcommitted
phy: phy_ethtool_ksettings_get: Lock the phy for consistency
The PHY structure should be locked while copying information out if it, otherwise there is no guarantee of self consistency. Without the lock the PHY state machine could be updating the structure. Fixes: 2d55173 ("phy: add generic function to support ksetting support") Signed-off-by: Andrew Lunn <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 95a359c commit c10a485

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

drivers/net/phy/phy.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,7 @@ EXPORT_SYMBOL(phy_ethtool_ksettings_set);
299299
void phy_ethtool_ksettings_get(struct phy_device *phydev,
300300
struct ethtool_link_ksettings *cmd)
301301
{
302+
mutex_lock(&phydev->lock);
302303
linkmode_copy(cmd->link_modes.supported, phydev->supported);
303304
linkmode_copy(cmd->link_modes.advertising, phydev->advertising);
304305
linkmode_copy(cmd->link_modes.lp_advertising, phydev->lp_advertising);
@@ -317,6 +318,7 @@ void phy_ethtool_ksettings_get(struct phy_device *phydev,
317318
cmd->base.autoneg = phydev->autoneg;
318319
cmd->base.eth_tp_mdix_ctrl = phydev->mdix_ctrl;
319320
cmd->base.eth_tp_mdix = phydev->mdix;
321+
mutex_unlock(&phydev->lock);
320322
}
321323
EXPORT_SYMBOL(phy_ethtool_ksettings_get);
322324

0 commit comments

Comments
 (0)