From: Jingyi Li <jinli@purestorage.com>
To: vkoul@kernel.org, vinicius.gomes@intel.com
Cc: dave.jiang@intel.com, xueshuai@linux.alibaba.com,
fenghuay@nvidia.com, Frank.Li@kernel.org,
dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org,
stable@vger.kernel.org, Jingyi Li <jinli@purestorage.com>
Subject: [PATCH 2/2] dmaengine: idxd: fix destroy of NULL or already destroyed workqueue
Date: Wed, 28 Oct 2026 00:37:07 +0000 [thread overview]
Message-ID: <20261028003708.834341-3-jinli@purestorage.com> (raw)
In-Reply-To: <20261028003708.834341-1-jinli@purestorage.com>
idxd_conf_device_release() unconditionally calls
destroy_workqueue(idxd->wq). This is wrong in two cases:
- If idxd_probe() fails before idxd_setup_internals() has created the
workqueue, for example when the device reports HALTED after reset,
idxd->wq is still NULL and the final put_device() in the probe error
path oopses:
BUG: kernel NULL pointer dereference, address: 00000000000000d0
RIP: 0010:destroy_workqueue+0xe/0x300
Call Trace:
<TASK>
idxd_conf_device_release+0x15/0x90 [idxd]
device_release+0x3c/0x90
kobject_put+0x7e/0x1e0
idxd_pci_probe_alloc+0x300/0x15e0 [idxd]
local_pci_probe+0x22/0x60
pci_device_probe+0xd4/0x260
- idxd_cleanup_internals() and the err_evl path of
idxd_setup_internals() destroy the workqueue but leave idxd->wq
pointing to it, so the release callback destroys it a second time.
Clear idxd->wq after the early destroys and skip the destroy in the
release callback when there is no workqueue.
We hit the NULL case in a kdump crash kernel, where the DSA device
fails to reset and the oops kills the crash kernel before the dump is
saved.
Fixes: 3d33de353b1f ("dmaengine: idxd: Fix not releasing workqueue on .release()")
Cc: stable@vger.kernel.org
Signed-off-by: Jingyi Li <jinli@purestorage.com>
---
drivers/dma/idxd/init.c | 2 ++
drivers/dma/idxd/sysfs.c | 3 ++-
2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/dma/idxd/init.c b/drivers/dma/idxd/init.c
index 1577d22b299c..5962cacef060 100644
--- a/drivers/dma/idxd/init.c
+++ b/drivers/dma/idxd/init.c
@@ -389,6 +389,7 @@ static void idxd_cleanup_internals(struct idxd_device *idxd)
idxd_clean_engines(idxd);
idxd_clean_wqs(idxd);
destroy_workqueue(idxd->wq);
+ idxd->wq = NULL;
}
static int idxd_init_evl(struct idxd_device *idxd)
@@ -460,6 +461,7 @@ static int idxd_setup_internals(struct idxd_device *idxd)
err_evl:
destroy_workqueue(idxd->wq);
+ idxd->wq = NULL;
err_wkq_create:
idxd_clean_groups(idxd);
err_group:
diff --git a/drivers/dma/idxd/sysfs.c b/drivers/dma/idxd/sysfs.c
index 6d251095c350..d5ffc641c856 100644
--- a/drivers/dma/idxd/sysfs.c
+++ b/drivers/dma/idxd/sysfs.c
@@ -1836,7 +1836,8 @@ static void idxd_conf_device_release(struct device *dev)
{
struct idxd_device *idxd = confdev_to_idxd(dev);
- destroy_workqueue(idxd->wq);
+ if (idxd->wq)
+ destroy_workqueue(idxd->wq);
kfree(idxd->groups);
bitmap_free(idxd->wq_enable_map);
kfree(idxd->wqs);
--
2.43.0
next prev parent reply other threads:[~2026-10-28 0:37 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-28 0:37 [PATCH 0/2] dmaengine: idxd: fix crashes in the probe error path Jingyi Li
2026-10-28 0:37 ` [PATCH 1/2] dmaengine: idxd: fix double free in idxd_free() Jingyi Li
2026-10-28 15:04 ` Frank Li
2026-10-28 0:37 ` Jingyi Li [this message]
2026-10-28 15:07 ` [PATCH 2/2] dmaengine: idxd: fix destroy of NULL or already destroyed workqueue Frank Li
2026-10-28 20:24 ` [PATCH 0/2] dmaengine: idxd: fix crashes in the probe error path Jingyi Li
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261028003708.834341-3-jinli@purestorage.com \
--to=jinli@purestorage.com \
--cc=Frank.Li@kernel.org \
--cc=dave.jiang@intel.com \
--cc=dmaengine@vger.kernel.org \
--cc=fenghuay@nvidia.com \
--cc=linux-kernel@vger.kernel.org \
--cc=stable@vger.kernel.org \
--cc=vinicius.gomes@intel.com \
--cc=vkoul@kernel.org \
--cc=xueshuai@linux.alibaba.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.