There is a race condition where the PHY state machine can change
members of the phydev structure at the same time userspace requests a
change via ethtool. To prevent this, have phy_ethtool_ksettings_set
take the PHY lock.
Fixes: 2d55173e71b0 ("phy: add generic function to support ksetting support")
Reported-by: Walter Stoll <Walter.Stoll@duagon.com>
Suggested-by: Walter Stoll <Walter.Stoll@duagon.com>
Tested-by: Walter Stoll <Walter.Stoll@duagon.com>
Signed-off-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
              duplex != DUPLEX_FULL)))
                return -EINVAL;
 
+       mutex_lock(&phydev->lock);
        phydev->autoneg = autoneg;
 
        if (autoneg == AUTONEG_DISABLE) {
        phydev->mdix_ctrl = cmd->base.eth_tp_mdix_ctrl;
 
        /* Restart the PHY */
-       phy_start_aneg(phydev);
+       _phy_start_aneg(phydev);
 
+       mutex_unlock(&phydev->lock);
        return 0;
 }
 EXPORT_SYMBOL(phy_ethtool_ksettings_set);