Skip to content

Commit 1d8476b

Browse files
committed
eth: via-rhine: fix calling napi_enable() in atomic context
JIRA: https://issues.redhat.com/browse/RHEL-87382 commit 09a9394 Author: Jakub Kicinski <kuba@kernel.org> Date: Thu Jan 23 19:18:40 2025 -0800 eth: via-rhine: fix calling napi_enable() in atomic context napi_enable() may sleep now, take netdev_lock() before rp->lock. napi_enable() is hidden inside init_registers(). Note that this patch orders netdev_lock after rp->task_lock, to avoid having to take the netdev_lock() around disable path. Fixes: 413f027 ("net: protect NAPI enablement with netdev_lock()") Reported-by: Dan Carpenter <dan.carpenter@linaro.org> Link: https://lore.kernel.org/dcfd56bc-de32-4b11-9e19-d8bd1543745d@stanley.mountain Reviewed-by: Eric Dumazet <edumazet@google.com> Link: https://patch.msgid.link/20250124031841.1179756-7-kuba@kernel.org Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Mohammad Heib <mheib@redhat.com>
1 parent 673466e commit 1d8476b

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

drivers/net/ethernet/via/via-rhine.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1571,7 +1571,7 @@ static void init_registers(struct net_device *dev)
15711571
if (rp->quirks & rqMgmt)
15721572
rhine_init_cam_filter(dev);
15731573

1574-
napi_enable(&rp->napi);
1574+
napi_enable_locked(&rp->napi);
15751575

15761576
iowrite16(RHINE_EVENT & 0xffff, ioaddr + IntrEnable);
15771577

@@ -1699,7 +1699,10 @@ static int rhine_open(struct net_device *dev)
16991699
rhine_power_init(dev);
17001700
rhine_chip_reset(dev);
17011701
rhine_task_enable(rp);
1702+
1703+
netdev_lock(dev);
17021704
init_registers(dev);
1705+
netdev_unlock(dev);
17031706

17041707
netif_dbg(rp, ifup, dev, "%s() Done - status %04x MII status: %04x\n",
17051708
__func__, ioread16(ioaddr + ChipCmd),
@@ -1730,6 +1733,8 @@ static void rhine_reset_task(struct work_struct *work)
17301733

17311734
napi_disable(&rp->napi);
17321735
netif_tx_disable(dev);
1736+
1737+
netdev_lock(dev);
17331738
spin_lock_bh(&rp->lock);
17341739

17351740
/* clear all descriptors */
@@ -1743,6 +1748,7 @@ static void rhine_reset_task(struct work_struct *work)
17431748
init_registers(dev);
17441749

17451750
spin_unlock_bh(&rp->lock);
1751+
netdev_unlock(dev);
17461752

17471753
netif_trans_update(dev); /* prevent tx timeout */
17481754
dev->stats.tx_errors++;
@@ -2546,9 +2552,12 @@ static int rhine_resume(struct device *device)
25462552
alloc_tbufs(dev);
25472553
rhine_reset_rbufs(rp);
25482554
rhine_task_enable(rp);
2555+
2556+
netdev_lock(dev);
25492557
spin_lock_bh(&rp->lock);
25502558
init_registers(dev);
25512559
spin_unlock_bh(&rp->lock);
2560+
netdev_unlock(dev);
25522561

25532562
netif_device_attach(dev);
25542563

0 commit comments

Comments
 (0)