Skip to content

Commit

Permalink
net: phy: always call phy_process_state_change() under lock
Browse files Browse the repository at this point in the history
phy_stop() calls phy_process_state_change() while holding the phydev
lock, so also arrange for phy_state_machine() to do the same, so that
this function is called with consistent locking.

Tested-by: Jijie Shao <shaojijie@huawei.com>
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Russell King (Oracle) authored and David S. Miller committed Sep 17, 2023
1 parent 002841b commit 8da77df
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/net/phy/phy.c
Original file line number Diff line number Diff line change
Expand Up @@ -1506,6 +1506,7 @@ void phy_state_machine(struct work_struct *work)
if (err < 0)
phy_error_precise(phydev, func, err);

mutex_lock(&phydev->lock);
phy_process_state_change(phydev, old_state);

/* Only re-schedule a PHY state machine change if we are polling the
Expand All @@ -1516,7 +1517,6 @@ void phy_state_machine(struct work_struct *work)
* state machine would be pointless and possibly error prone when
* called from phy_disconnect() synchronously.
*/
mutex_lock(&phydev->lock);
if (phy_polling_mode(phydev) && phy_is_started(phydev))
phy_queue_state_machine(phydev, PHY_STATE_TIME);
mutex_unlock(&phydev->lock);
Expand Down

0 comments on commit 8da77df

Please sign in to comment.