linux/include
Breno Leitao 0de4cb473a workqueue: fix devm_alloc_workqueue() va_list misuse
devm_alloc_workqueue() built a va_list and passed it as a single
positional argument to the variadic alloc_workqueue() macro:

	va_start(args, max_active);
	wq = alloc_workqueue(fmt, flags, max_active, args);
	va_end(args);

C does not allow forwarding a va_list through a ... parameter.
alloc_workqueue() expands to alloc_workqueue_noprof(), which runs
its own va_start() over its ... params, so the inner
vsnprintf(wq->name, sizeof(wq->name), fmt, args) in
__alloc_workqueue() received the outer va_list object as the first
variadic slot rather than the caller's actual format arguments.

Add a new static helper alloc_workqueue_va() that wraps
__alloc_workqueue() and runs wq_init_lockdep() on success, and
fold both alloc_workqueue_noprof() and devm_alloc_workqueue_noprof()
onto it as suggested by Tejun.

The wq_init_lockdep() step is required on the devm path
too, otherwise __flush_workqueue()'s on-stack
COMPLETION_INITIALIZER_ONSTACK_MAP would NULL-deref wq->lockdep_map.

No caller changes are required. devm_alloc_ordered_workqueue() is
a macro forwarding to devm_alloc_workqueue() and inherits the fix.
Two in-tree callers actively trigger the broken path on every probe:

  drivers/power/supply/mt6370-charger.c:889
  drivers/power/supply/max77705_charger.c:649

both of which use devm_alloc_ordered_workqueue(dev, "%s", 0,
dev_name(dev)).

A standalone reproducer module is available at[1].

Link: https://github.com/leitao/debug/blob/main/workqueue/valist/wq_va_test.c [1]
Fixes: 1dfc9d60a6 ("workqueue: devres: Add device-managed allocate workqueue")
Signed-off-by: Breno Leitao <leitao@debian.org>
Signed-off-by: Tejun Heo <tj@kernel.org>
2026-04-28 06:13:40 -10:00
..
acpi Power management updates for 7.1-rc1 2026-04-13 19:47:52 -07:00
asm-generic hyperv-next for v7.1 2026-04-22 09:50:46 -07:00
clocksource
crypto This update includes the following changes: 2026-04-15 15:22:26 -07:00
cxl
drm Char/Misc/IIO/and others driver updates for 7.1-rc1 2026-04-24 13:23:50 -07:00
dt-bindings We've finally gotten rid of the struct clk_ops::round_rate() code after months 2026-04-21 08:33:26 -07:00
hyperv x86/hyperv: Skip LP/VP creation on kexec 2026-04-22 06:23:25 +00:00
keys
kunit
kvm KVM: arm64: Kill arch_timer_context::direct field 2026-04-01 15:42:26 +01:00
linux workqueue: fix devm_alloc_workqueue() va_list misuse 2026-04-28 06:13:40 -10:00
math-emu
media
memory
misc
net - 9p access flag fix (cannot change access flag since new mount API implem) 2026-04-24 13:37:26 -07:00
pcmcia
ras
rdma
rv
scsi scsi: libsas: Delete unused to_dom_device() and to_dev_attr() 2026-04-08 21:55:51 -04:00
soc firmware: tegra: Changes for v7.1-rc1 2026-04-02 23:13:02 +02:00
sound ASoC: Fixes for v7.1 2026-04-23 09:34:28 +02:00
target
trace NFS client updates for Linux 7.1 2026-04-24 14:20:03 -07:00
uapi Delete some obsolete networking code 2026-04-24 09:41:58 -07:00
ufs
vdso
video
xen xen/grant-table: guard gnttab_suspend/resume with CONFIG_HIBERNATE_CALLBACKS 2026-04-10 11:07:21 +02:00
Kbuild