Merge branch 'fix-missing-rtnl-lock-in-suspend-path'

Kory Maincent says:

====================
Fix missing rtnl lock in suspend path

Fix the suspend path by ensuring the rtnl lock is held where required.
Calls to open, close and WOL operations must be performed under the
rtnl lock to prevent conflicts with ongoing ndo operations.

Discussion about this issue can be found here:
https://lore.kernel.org/netdev/20250120141926.1290763-1-kory.maincent@bootlin.com/

While working on the ravb fix, it was discovered that the sh_eth driver
has the same issue. This patch series addresses both drivers.

I do not have access to hardware for either of these MACs, so it would
be great if maintainers or others with the relevant boards could test
these fixes.

v2: https://lore.kernel.org/r/20250123-fix_missing_rtnl_lock_phy_disconnect-v2-0-e6206f5508ba@bootlin.com

v1: https://lore.kernel.org/r/20250122-fix_missing_rtnl_lock_phy_disconnect-v1-0-8cb9f6f88fd1@bootlin.com

Signed-off-by: Kory Maincent <kory.maincent@bootlin.com>
====================

Link: https://patch.msgid.link/20250129-fix_missing_rtnl_lock_phy_disconnect-v3-0-24c4ba185a92@bootlin.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
This commit is contained in:
Paolo Abeni 2025-01-30 11:23:32 +01:00
commit 3effcc04d8
2 changed files with 18 additions and 8 deletions

View File

@ -3217,10 +3217,15 @@ static int ravb_suspend(struct device *dev)
netif_device_detach(ndev);
if (priv->wol_enabled)
return ravb_wol_setup(ndev);
rtnl_lock();
if (priv->wol_enabled) {
ret = ravb_wol_setup(ndev);
rtnl_unlock();
return ret;
}
ret = ravb_close(ndev);
rtnl_unlock();
if (ret)
return ret;
@ -3245,19 +3250,20 @@ static int ravb_resume(struct device *dev)
if (!netif_running(ndev))
return 0;
rtnl_lock();
/* If WoL is enabled restore the interface. */
if (priv->wol_enabled) {
if (priv->wol_enabled)
ret = ravb_wol_restore(ndev);
if (ret)
return ret;
} else {
else
ret = pm_runtime_force_resume(dev);
if (ret)
return ret;
if (ret) {
rtnl_unlock();
return ret;
}
/* Reopening the interface will restore the device to the working state. */
ret = ravb_open(ndev);
rtnl_unlock();
if (ret < 0)
goto out_rpm_put;

View File

@ -3494,10 +3494,12 @@ static int sh_eth_suspend(struct device *dev)
netif_device_detach(ndev);
rtnl_lock();
if (mdp->wol_enabled)
ret = sh_eth_wol_setup(ndev);
else
ret = sh_eth_close(ndev);
rtnl_unlock();
return ret;
}
@ -3511,10 +3513,12 @@ static int sh_eth_resume(struct device *dev)
if (!netif_running(ndev))
return 0;
rtnl_lock();
if (mdp->wol_enabled)
ret = sh_eth_wol_restore(ndev);
else
ret = sh_eth_open(ndev);
rtnl_unlock();
if (ret < 0)
return ret;