提交 c10a485c 编写于 作者: A Andrew Lunn 提交者: David S. Miller

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: 2d55173e ("phy: add generic function to support ksetting support")
Signed-off-by: NAndrew Lunn <andrew@lunn.ch>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 95a359c9
...@@ -299,6 +299,7 @@ EXPORT_SYMBOL(phy_ethtool_ksettings_set); ...@@ -299,6 +299,7 @@ EXPORT_SYMBOL(phy_ethtool_ksettings_set);
void phy_ethtool_ksettings_get(struct phy_device *phydev, void phy_ethtool_ksettings_get(struct phy_device *phydev,
struct ethtool_link_ksettings *cmd) struct ethtool_link_ksettings *cmd)
{ {
mutex_lock(&phydev->lock);
linkmode_copy(cmd->link_modes.supported, phydev->supported); linkmode_copy(cmd->link_modes.supported, phydev->supported);
linkmode_copy(cmd->link_modes.advertising, phydev->advertising); linkmode_copy(cmd->link_modes.advertising, phydev->advertising);
linkmode_copy(cmd->link_modes.lp_advertising, phydev->lp_advertising); linkmode_copy(cmd->link_modes.lp_advertising, phydev->lp_advertising);
...@@ -317,6 +318,7 @@ void phy_ethtool_ksettings_get(struct phy_device *phydev, ...@@ -317,6 +318,7 @@ void phy_ethtool_ksettings_get(struct phy_device *phydev,
cmd->base.autoneg = phydev->autoneg; cmd->base.autoneg = phydev->autoneg;
cmd->base.eth_tp_mdix_ctrl = phydev->mdix_ctrl; cmd->base.eth_tp_mdix_ctrl = phydev->mdix_ctrl;
cmd->base.eth_tp_mdix = phydev->mdix; cmd->base.eth_tp_mdix = phydev->mdix;
mutex_unlock(&phydev->lock);
} }
EXPORT_SYMBOL(phy_ethtool_ksettings_get); EXPORT_SYMBOL(phy_ethtool_ksettings_get);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册