Skip to content

Commit e5235eb

Browse files
leitaokuba-moo
authored andcommitted
net: netpoll: initialize work queue before error checks
Prevent a kernel warning when netconsole setup fails on devices with IFF_DISABLE_NETPOLL flag. The warning (at kernel/workqueue.c:4242 in __flush_work) occurs because the cleanup path tries to cancel an uninitialized work queue. When __netpoll_setup() encounters a device with IFF_DISABLE_NETPOLL, it fails early and calls skb_pool_flush() for cleanup. This function calls cancel_work_sync(&np->refill_wq), but refill_wq hasn't been initialized yet, triggering the warning. Move INIT_WORK() to the beginning of __netpoll_setup(), ensuring the work queue is properly initialized before any potential failure points. This allows the cleanup path to safely cancel the work queue regardless of where the setup fails. Fixes: 248f657 ("netpoll: Optimize skb refilling on critical path") Signed-off-by: Breno Leitao <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 2c28ee7 commit e5235eb

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

net/core/netpoll.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -554,6 +554,7 @@ int __netpoll_setup(struct netpoll *np, struct net_device *ndev)
554554
int err;
555555

556556
skb_queue_head_init(&np->skb_pool);
557+
INIT_WORK(&np->refill_wq, refill_skbs_work_handler);
557558

558559
if (ndev->priv_flags & IFF_DISABLE_NETPOLL) {
559560
np_err(np, "%s doesn't support polling, aborting\n",
@@ -591,7 +592,6 @@ int __netpoll_setup(struct netpoll *np, struct net_device *ndev)
591592

592593
/* fill up the skb queue */
593594
refill_skbs(np);
594-
INIT_WORK(&np->refill_wq, refill_skbs_work_handler);
595595

596596
/* last thing to do is link it to the net device structure */
597597
rcu_assign_pointer(ndev->npinfo, npinfo);

0 commit comments

Comments
 (0)