diff options
author | Andrew Lunn <andrew@lunn.ch> | 2021-10-24 21:48:02 +0200 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2021-11-02 19:46:14 +0100 |
commit | c85b696270db3bf5c57fc0eb30548cfafc00bc3a (patch) | |
tree | b0c90dfdca1c3a3184660c8bee87e35ce75136df | |
parent | 0dea6379e273dba1cd7e19aad298f8c59f75288c (diff) | |
download | linux-stable-c85b696270db3bf5c57fc0eb30548cfafc00bc3a.tar.gz linux-stable-c85b696270db3bf5c57fc0eb30548cfafc00bc3a.tar.bz2 linux-stable-c85b696270db3bf5c57fc0eb30548cfafc00bc3a.zip |
phy: phy_ethtool_ksettings_get: Lock the phy for consistency
commit c10a485c3de5ccbf1fff65a382cebcb2730c6b06 upstream.
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: 2d55173e71b0 ("phy: add generic function to support ksetting support")
Signed-off-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | drivers/net/phy/phy.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c index b0b8a3ce82b6..168a36857036 100644 --- a/drivers/net/phy/phy.c +++ b/drivers/net/phy/phy.c @@ -367,6 +367,7 @@ EXPORT_SYMBOL(phy_ethtool_ksettings_set); void phy_ethtool_ksettings_get(struct phy_device *phydev, struct ethtool_link_ksettings *cmd) { + mutex_lock(&phydev->lock); linkmode_copy(cmd->link_modes.supported, phydev->supported); linkmode_copy(cmd->link_modes.advertising, phydev->advertising); linkmode_copy(cmd->link_modes.lp_advertising, phydev->lp_advertising); @@ -383,6 +384,7 @@ void phy_ethtool_ksettings_get(struct phy_device *phydev, cmd->base.autoneg = phydev->autoneg; cmd->base.eth_tp_mdix_ctrl = phydev->mdix_ctrl; cmd->base.eth_tp_mdix = phydev->mdix; + mutex_unlock(&phydev->lock); } EXPORT_SYMBOL(phy_ethtool_ksettings_get); |