netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net] net: netpoll: initialize work queue before error checks
@ 2025-11-27 15:30 Breno Leitao
  2025-11-29  4:30 ` patchwork-bot+netdevbpf
  0 siblings, 1 reply; 2+ messages in thread
From: Breno Leitao @ 2025-11-27 15:30 UTC (permalink / raw)
  To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Simon Horman
  Cc: netdev, linux-kernel, gustavold, asantostc, kernel-team,
	Breno Leitao

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: 248f6571fd4c5 ("netpoll: Optimize skb refilling on critical path")
Signed-off-by: Breno Leitao <leitao@debian.org>
---
 net/core/netpoll.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/core/netpoll.c b/net/core/netpoll.c
index 331764845e8f..09f72f10813c 100644
--- a/net/core/netpoll.c
+++ b/net/core/netpoll.c
@@ -554,6 +554,7 @@ int __netpoll_setup(struct netpoll *np, struct net_device *ndev)
 	int err;
 
 	skb_queue_head_init(&np->skb_pool);
+	INIT_WORK(&np->refill_wq, refill_skbs_work_handler);
 
 	if (ndev->priv_flags & IFF_DISABLE_NETPOLL) {
 		np_err(np, "%s doesn't support polling, aborting\n",
@@ -591,7 +592,6 @@ int __netpoll_setup(struct netpoll *np, struct net_device *ndev)
 
 	/* fill up the skb queue */
 	refill_skbs(np);
-	INIT_WORK(&np->refill_wq, refill_skbs_work_handler);
 
 	/* last thing to do is link it to the net device structure */
 	rcu_assign_pointer(ndev->npinfo, npinfo);

---
base-commit: f07f4ea53e22429c84b20832fa098b5ecc0d4e35
change-id: 20251127-netpoll_fix_init_work-5e4df6c57cf2

Best regards,
--  
Breno Leitao <leitao@debian.org>


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH net] net: netpoll: initialize work queue before error checks
  2025-11-27 15:30 [PATCH net] net: netpoll: initialize work queue before error checks Breno Leitao
@ 2025-11-29  4:30 ` patchwork-bot+netdevbpf
  0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-11-29  4:30 UTC (permalink / raw)
  To: Breno Leitao
  Cc: davem, edumazet, kuba, pabeni, horms, netdev, linux-kernel,
	gustavold, asantostc, kernel-team

Hello:

This patch was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Thu, 27 Nov 2025 07:30:15 -0800 you wrote:
> 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.
> 
> [...]

Here is the summary with links:
  - [net] net: netpoll: initialize work queue before error checks
    https://git.kernel.org/netdev/net/c/e5235eb6cfe0

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-11-29  4:33 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-27 15:30 [PATCH net] net: netpoll: initialize work queue before error checks Breno Leitao
2025-11-29  4:30 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).