Re: [PATCH] dmaengine: idxd: Avoid destroying the device workqueue twice
From: Vinicius Costa Gomes
Date: Wed Nov 25 2026 - 19:09:53 EST
Hi,
Yao Kai <yaokai34@xxxxxxxxxx> writes:
> If idxd_probe() fails after idxd_setup_internals() succeeds,
> idxd_cleanup_internals() destroys idxd->wq. The PCI probe error path
> then calls idxd_free(), whose put_device() invokes
> idxd_conf_device_release() and destroys the same workqueue again.
> The err_evl path in idxd_setup_internals() has the same problem.
> This can corrupt the workqueue list or access freed memory.
>
> Clear idxd->wq after both error-path destroy_workqueue() calls and
> only destroy a non-NULL workqueue in the release callback. The NULL
> check also handles failures before the workqueue is created, while
> preserving its destruction on normal device removal.
>
> Fixes: 3d33de353b1f ("dmaengine: idxd: Fix not releasing workqueue on .release()")
> Cc: stable@xxxxxxxxxxxxxxx
> Signed-off-by: Yao Kai <yaokai34@xxxxxxxxxx>
> ---
I just sent v2 of the idxd-fixes series [1]. Setting ->wq to NULL
doesn't fix the double frees of ->wqs, ->engines, ->groups (and
friends) on the same error paths. My approach was a bit more general:
remove the early frees and the early destroy_workqueue(), and rely on
the kobject .release callback to free everything.
But if folks prefer this approach, I would gladly rebase my series on
top of this one.
https://lore.kernel.org/all/20261125-wt-idxd-fixes-v2-0-25a4691dfb9e@xxxxxxxxx/
Cheers,
--
Vinicius