Commit 8a711029 authored by Kory Maincent's avatar Kory Maincent Committed by Wentao Guan
Browse files

net: sh_eth: Fix missing rtnl lock in suspend/resume path

stable inclusion
from stable-v6.6.76
commit f59acc3f9441ff662d203e6c4e7c1c5298badb37
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/IBW08Q

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=f59acc3f9441ff662d203e6c4e7c1c5298badb37



--------------------------------

[ Upstream commit b95102215a8d0987789715ce11c0d4ec031cbfbe ]

Fix the suspend/resume path by ensuring the rtnl lock is held where
required. Calls to sh_eth_close, sh_eth_open and wol operations must be
performed under the rtnl lock to prevent conflicts with ongoing ndo
operations.

Fixes: b71af046 ("sh_eth: add more PM methods")
Tested-by: default avatarNiklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Reviewed-by: default avatarSergey Shtylyov <s.shtylyov@omp.ru>
Signed-off-by: default avatarKory Maincent <kory.maincent@bootlin.com>
Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
(cherry picked from commit f59acc3f9441ff662d203e6c4e7c1c5298badb37)
Signed-off-by: default avatarWentao Guan <guanwentao@uniontech.com>
parent 6e2ae77c
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -3496,10 +3496,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;
}
@@ -3513,10 +3515,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;