[PATCH net] net: spacemit: Hold RTNL lock in emac_resume() and emac_suspend()
Ali Tariq
alitariq45892 at gmail.com
Thu Nov 5 04:34:37 PST 2026
The emac_resume() calls the emac_open() and emac_suspend() calls
emac_stop() functions directly without holding the lock through
rtnl_lock(). These functions rely on phy_disconnect() which reads pointer
with rtnl_dereference(). But since no lock is being held,
rtnl_dereference throws a suspicious RCU usage on
Orange Pi RV2 (SpacemiT K1) warning when lockdep is enabled.
WARNING: suspicious RCU usage
drivers/net/phy/phy_device.c:1831 suspicious rcu_dereference_protected() usage!
Call Trace:
phy_detach_internal+0x490/0x5f2
phy_disconnect+0x90/0xc0
emac_stop+0x114/0x626
emac_suspend+0xac/0x126
platform_pm_suspend+0x72/0xe4
Hold RTNL lock before emac_open() and emac_stop() with rtnl_lock() and
release the lock when functions return with rtnl_unlock().
Fixes: bfec6d7f2001 ("net: spacemit: Add K1 Ethernet MAC")
Signed-off-by: Ali Tariq <alitariq45892 at gmail.com>
---
Warning Log: https://kernelci.cloud-v.co/scheduler/job/549#L2168
Fixed Log: https://kernelci.cloud-v.co/scheduler/job/557
---
drivers/net/ethernet/spacemit/k1_emac.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/net/ethernet/spacemit/k1_emac.c b/drivers/net/ethernet/spacemit/k1_emac.c
index 71a80838bffd..aca25a9e1e9e 100644
--- a/drivers/net/ethernet/spacemit/k1_emac.c
+++ b/drivers/net/ethernet/spacemit/k1_emac.c
@@ -2033,7 +2033,10 @@ static int emac_resume(struct device *dev)
if (!netif_running(ndev))
return 0;
+ rtnl_lock();
ret = emac_open(ndev);
+ rtnl_unlock();
+
if (ret) {
clk_disable_unprepare(priv->bus_clk);
return ret;
@@ -2056,7 +2059,9 @@ static int emac_suspend(struct device *dev)
return 0;
}
+ rtnl_lock();
emac_stop(ndev);
+ rtnl_unlock();
clk_disable_unprepare(priv->bus_clk);
netif_device_detach(ndev);
--
2.34.1
More information about the linux-riscv
mailing list