From: Shuai Xue <xueshuai@linux.alibaba.com>
To: vinicius.gomes@intel.com, dave.jiang@intel.com,
fenghuay@nvidia.com, vkoul@kernel.org
Cc: xueshuai@linux.alibaba.com, dmaengine@vger.kernel.org,
colin.i.king@gmail.com, linux-kernel@vger.kernel.org
Subject: [PATCH v1 2/2] dmaengine: idxd: fix potential NULL pointer dereference on wq setup error path
Date: Thu, 22 May 2025 14:33:29 +0800 [thread overview]
Message-ID: <20250522063329.51156-3-xueshuai@linux.alibaba.com> (raw)
In-Reply-To: <20250522063329.51156-1-xueshuai@linux.alibaba.com>
If wq allocation fails during the initial iteration of the loop,
`conf_dev` is still NULL. However, the existing error handling via
`goto err` would attempt to call `put_device(conf_dev)`, leading to a
NULL pointer dereference.
This issue occurs because there's no dedicated error label for the WQ
allocation failure case, causing it to fall through to an incorrect
error path.
Fix this by introducing a new error label `err_wq`, ensuring that we
only invoke `put_device(conf_dev)` when `conf_dev` is valid.
Fixes: 3fd2f4bc010c ("dmaengine: idxd: fix memory leak in error handling path of idxd_setup_wqs")
Cc: stable@vger.kernel.org
Reported-by: Colin King <colin.i.king@gmail.com>
Signed-off-by: Shuai Xue <xueshuai@linux.alibaba.com>
---
drivers/dma/idxd/init.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/dma/idxd/init.c b/drivers/dma/idxd/init.c
index 760b7d81fcd8..bf57ad30d613 100644
--- a/drivers/dma/idxd/init.c
+++ b/drivers/dma/idxd/init.c
@@ -196,7 +196,7 @@ static int idxd_setup_wqs(struct idxd_device *idxd)
wq = kzalloc_node(sizeof(*wq), GFP_KERNEL, dev_to_node(dev));
if (!wq) {
rc = -ENOMEM;
- goto err;
+ goto err_wq;
}
idxd_dev_set_type(&wq->idxd_dev, IDXD_DEV_WQ);
@@ -246,6 +246,7 @@ static int idxd_setup_wqs(struct idxd_device *idxd)
put_device(conf_dev);
kfree(wq);
+err_wq:
while (--i >= 0) {
wq = idxd->wqs[i];
if (idxd->hw.wq_cap.op_config)
--
2.43.5
next prev parent reply other threads:[~2025-05-22 6:38 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-22 6:33 [PATCH v1 0/2] dmaengine: idxd: minor fixes for idxd driver Shuai Xue
2025-05-22 6:33 ` [PATCH v1 1/2] dmaengine: idxd: Fix race condition between WQ enable and reset paths Shuai Xue
2025-05-22 14:55 ` Dave Jiang
2025-05-23 5:20 ` Shuai Xue
2025-05-23 14:54 ` Dave Jiang
2025-05-24 5:40 ` Shuai Xue
2025-05-28 2:21 ` Vinicius Costa Gomes
2025-06-03 14:32 ` Dave Jiang
2025-06-04 8:55 ` Shuai Xue
2025-06-04 14:19 ` Dave Jiang
2025-06-05 7:40 ` Shuai Xue
2025-06-06 14:32 ` Dave Jiang
2025-06-16 1:54 ` Shuai Xue
2025-06-16 15:22 ` Dave Jiang
2025-05-22 6:33 ` Shuai Xue [this message]
2025-05-22 14:56 ` [PATCH v1 2/2] dmaengine: idxd: fix potential NULL pointer dereference on wq setup error path Dave Jiang
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=20250522063329.51156-3-xueshuai@linux.alibaba.com \
--to=xueshuai@linux.alibaba.com \
--cc=colin.i.king@gmail.com \
--cc=dave.jiang@intel.com \
--cc=dmaengine@vger.kernel.org \
--cc=fenghuay@nvidia.com \
--cc=linux-kernel@vger.kernel.org \
--cc=vinicius.gomes@intel.com \
--cc=vkoul@kernel.org \
/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 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®