* [PATCH wq/for-7.4] workqueue: BUG_ON() a pwq release before workqueue_init()
@ 2026-09-11 10:26 Breno Leitao
2026-09-11 14:52 ` Tejun Heo
0 siblings, 1 reply; 2+ messages in thread
From: Breno Leitao @ 2026-09-11 10:26 UTC (permalink / raw)
To: Tejun Heo, Lai Jiangshan; +Cc: linux-kernel, kernel-team, Breno Leitao
put_pwq() bounces the release to pwq_release_worker to get out from
under pool->lock. workqueue_init() creates that kthread_worker well
after workqueue_init_early() has built the system workqueues, so a pwq
allocation failing partway through apply_wqattrs_prepare() unwinds
through apply_wqattrs_cleanup() and dereferences a NULL worker.
There is no way back from that. Running the release inline is not an
option, that is what the bounce exists for, and workqueue_init_early()
already BUG_ON()s a system workqueue it failed to allocate.
BUG_ON() the missing worker instead of oopsing inside
kthread_queue_work().
Suggested-by: Tejun Heo <tj@kernel.org>
Link: https://lore.kernel.org/all/144b3dc986135ebe34f671cdd02bd8aa@kernel.org/
Signed-off-by: Breno Leitao <leitao@debian.org>
---
kernel/workqueue.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index 39187f424c34e7..e618108c6127da 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -1771,6 +1771,14 @@ static void put_pwq(struct pool_workqueue *pwq)
lockdep_assert_held(&pwq->pool->lock);
if (likely(--pwq->refcnt))
return;
+
+ /*
+ * pwq_release_worker is only created in workqueue_init(). Getting
+ * here before that means an early workqueue allocation failed, which
+ * is fatal anyway.
+ */
+ BUG_ON(!pwq_release_worker);
+
/*
* @pwq can't be released under pool->lock, bounce to a dedicated
* kthread_worker to avoid A-A deadlocks.
---
base-commit: d8c2ce77cd09077ec57c4bed5678f76425157ccd
change-id: 20260911-tejun_bug_on-5b72d9012b12
Best regards,
--
Breno Leitao <leitao@debian.org>
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH wq/for-7.4] workqueue: BUG_ON() a pwq release before workqueue_init()
2026-09-11 10:26 [PATCH wq/for-7.4] workqueue: BUG_ON() a pwq release before workqueue_init() Breno Leitao
@ 2026-09-11 14:52 ` Tejun Heo
0 siblings, 0 replies; 2+ messages in thread
From: Tejun Heo @ 2026-09-11 14:52 UTC (permalink / raw)
To: Breno Leitao; +Cc: Tejun Heo, Lai Jiangshan, linux-kernel, kernel-team
Hello,
Applied to wq/for-7.4.
Thanks.
--
tejun
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-09-11 14:52 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-11 10:26 [PATCH wq/for-7.4] workqueue: BUG_ON() a pwq release before workqueue_init() Breno Leitao
2026-09-11 14:52 ` Tejun Heo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®