Skip to content

Commit

Permalink
Merge branch 'fix-missing-rtnl-lock-in-suspend-path'
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Paolo Abeni committed Jan 30, 2025
2 parents da5ca22 + b951022 commit 3effcc0
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
22 changes: 14 additions & 8 deletions drivers/net/ethernet/renesas/ravb_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;

Expand Down
4 changes: 4 additions & 0 deletions drivers/net/ethernet/renesas/sh_eth.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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;
Expand Down

0 comments on commit 3effcc0

Please sign in to comment.