From: Vinicius Costa Gomes <vinicius.gomes@intel.com>
To: Dave Jiang <dave.jiang@intel.com>, Vinod Koul <vkoul@kernel.org>,
Frank Li <Frank.Li@kernel.org>, Fenghua Yu <fenghuay@nvidia.com>,
Shuai Xue <xueshuai@linux.alibaba.com>
Cc: dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org,
Vinicius Costa Gomes <vinicius.gomes@intel.com>,
stable@vger.kernel.org, Jingyi Li <jinli@purestorage.com>
Subject: [PATCH v2 2/8] dmaengine: idxd: Fix potential double free on probe error path
Date: Wed, 25 Nov 2026 15:49:00 -0800 [thread overview]
Message-ID: <20261125-wt-idxd-fixes-v2-2-25a4691dfb9e@intel.com> (raw)
In-Reply-To: <20261125-wt-idxd-fixes-v2-0-25a4691dfb9e@intel.com>
On the probe error path, put_device() calls idxd_conf_device_release().
It frees idxd->wq and the wqs, engines, groups and wq_enable_map arrays.
idxd_cleanup_internals(), the idxd_clean_*() helpers and the
idxd_setup_*() error paths free the same objects again.
Commit ec2d428b2e32 ("dmaengine: idxd: fix double free of wq, engine,
and group structs") removed the duplicate frees of the wq, engine and
group structs, but left these. Remove them.
Keep flushing the workqueue in idxd_cleanup_internals(). Work queued by
the misc interrupt uses the registers, which are unmapped before the
release callback runs.
Fixes: 3d33de353b1f ("dmaengine: idxd: Fix not releasing workqueue on .release()")
Cc: stable@vger.kernel.org # 6.6.x: ec2d428b2e32: dmaengine: idxd: fix double free of wq, engine, and group structs
Cc: stable@vger.kernel.org # 6.6.x
Link: https://lore.kernel.org/all/20260615103932.61828-1-bogdan.codres@windriver.com/
Tested-by: Jingyi Li <jinli@purestorage.com>
Reviewed-by: Dave Jiang <dave.jiang@intel.com>
Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@intel.com>
---
drivers/dma/idxd/init.c | 13 ++-----------
1 file changed, 2 insertions(+), 11 deletions(-)
diff --git a/drivers/dma/idxd/init.c b/drivers/dma/idxd/init.c
index 4b827a329756..9aab57a4b13e 100644
--- a/drivers/dma/idxd/init.c
+++ b/drivers/dma/idxd/init.c
@@ -166,8 +166,6 @@ static void idxd_clean_wqs(struct idxd_device *idxd)
conf_dev = wq_confdev(idxd->wqs[i]);
put_device(conf_dev);
}
- bitmap_free(idxd->wq_enable_map);
- kfree(idxd->wqs);
}
static int idxd_setup_wqs(struct idxd_device *idxd)
@@ -245,11 +243,8 @@ static int idxd_setup_wqs(struct idxd_device *idxd)
conf_dev = wq_confdev(idxd->wqs[i]);
put_device(conf_dev);
}
- bitmap_free(idxd->wq_enable_map);
err_free_wqs:
- kfree(idxd->wqs);
-
return rc;
}
@@ -262,7 +257,6 @@ static void idxd_clean_engines(struct idxd_device *idxd)
conf_dev = engine_confdev(idxd->engines[i]);
put_device(conf_dev);
}
- kfree(idxd->engines);
}
static int idxd_setup_engines(struct idxd_device *idxd)
@@ -308,7 +302,6 @@ static int idxd_setup_engines(struct idxd_device *idxd)
conf_dev = engine_confdev(idxd->engines[i]);
put_device(conf_dev);
}
- kfree(idxd->engines);
return rc;
}
@@ -320,7 +313,6 @@ static void idxd_clean_groups(struct idxd_device *idxd)
for (i = 0; i < idxd->max_groups; i++) {
put_device(group_confdev(idxd->groups[i]));
}
- kfree(idxd->groups);
}
static int idxd_setup_groups(struct idxd_device *idxd)
@@ -378,17 +370,17 @@ static int idxd_setup_groups(struct idxd_device *idxd)
group = idxd->groups[i];
put_device(group_confdev(group));
}
- kfree(idxd->groups);
return rc;
}
static void idxd_cleanup_internals(struct idxd_device *idxd)
{
+ /* Queued work uses the groups, engines, WQs and the registers */
+ flush_workqueue(idxd->wq);
idxd_clean_groups(idxd);
idxd_clean_engines(idxd);
idxd_clean_wqs(idxd);
- destroy_workqueue(idxd->wq);
}
static int idxd_init_evl(struct idxd_device *idxd)
@@ -459,7 +451,6 @@ static int idxd_setup_internals(struct idxd_device *idxd)
return 0;
err_evl:
- destroy_workqueue(idxd->wq);
err_wkq_create:
idxd_clean_groups(idxd);
err_group:
--
2.56.1
next prev parent reply other threads:[~2026-11-25 23:49 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-25 23:48 [PATCH v2 0/8] dmaengine: idxd: More error handling fixes Vinicius Costa Gomes
2026-11-25 23:48 ` [PATCH v2 1/8] dmaengine: idxd: Do not call destroy_workqueue() with null idxd->wq Vinicius Costa Gomes
2026-11-25 23:49 ` Vinicius Costa Gomes [this message]
2026-11-25 23:49 ` [PATCH v2 3/8] dmaengine: idxd: fix duplicate memory frees on initialization error path Vinicius Costa Gomes
2026-11-25 23:49 ` [PATCH v2 4/8] dmaengine: idxd: Fix the device registration error paths Vinicius Costa Gomes
2026-11-25 23:49 ` [PATCH v2 5/8] dmaengine: idxd: Fix error handling in idxd_cdev_open() Vinicius Costa Gomes
2026-11-25 23:49 ` [PATCH v2 6/8] dmaengine: idxd: Initialize the WQ XArray before the WQ can be released Vinicius Costa Gomes
2026-11-25 23:49 ` [PATCH v2 7/8] dmaengine: idxd: Do not release interrupt handles on terminate_all() Vinicius Costa Gomes
2026-11-25 23:49 ` [PATCH v2 8/8] dmaengine: idxd: Don't flush the descriptors " Vinicius Costa Gomes
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=20261125-wt-idxd-fixes-v2-2-25a4691dfb9e@intel.com \
--to=vinicius.gomes@intel.com \
--cc=Frank.Li@kernel.org \
--cc=dave.jiang@intel.com \
--cc=dmaengine@vger.kernel.org \
--cc=fenghuay@nvidia.com \
--cc=jinli@purestorage.com \
--cc=linux-kernel@vger.kernel.org \
--cc=stable@vger.kernel.org \
--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 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®