Skip to content

Commit d3d9b17

Browse files
vcgomesopsiff
authored andcommitted
dmaengine: idxd: Fix freeing the allocated ida too late
[ Upstream commit c311f5e9248471a950f0a524c2fd736414d98900 ] It can happen that when the cdev .release() is called, the driver already called ida_destroy(). Move ida_free() to the _del() path. We see with DEBUG_KOBJECT_RELEASE enabled and forcing an early PCI unbind. Fixes: 04922b7 ("dmaengine: idxd: fix cdev setup and free device lifetime issues") Reviewed-by: Dave Jiang <dave.jiang@intel.com> Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@intel.com> Link: https://patch.msgid.link/20260121-idxd-fix-flr-on-kernel-queues-v3-v3-9-7ed70658a9d1@intel.com Signed-off-by: Vinod Koul <vkoul@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org> (cherry picked from commit 37cf97e37498ae1ca7b873e53e3f225a92ecee2d) Signed-off-by: Wentao Guan <guanwentao@uniontech.com>
1 parent 64100d8 commit d3d9b17

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

drivers/dma/idxd/cdev.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -161,11 +161,7 @@ static const struct device_type idxd_cdev_file_type = {
161161
static void idxd_cdev_dev_release(struct device *dev)
162162
{
163163
struct idxd_cdev *idxd_cdev = dev_to_cdev(dev);
164-
struct idxd_cdev_context *cdev_ctx;
165-
struct idxd_wq *wq = idxd_cdev->wq;
166164

167-
cdev_ctx = &ictx[wq->idxd->data->type];
168-
ida_free(&cdev_ctx->minor_ida, idxd_cdev->minor);
169165
kfree(idxd_cdev);
170166
}
171167

@@ -585,11 +581,15 @@ int idxd_wq_add_cdev(struct idxd_wq *wq)
585581

586582
void idxd_wq_del_cdev(struct idxd_wq *wq)
587583
{
584+
struct idxd_cdev_context *cdev_ctx;
588585
struct idxd_cdev *idxd_cdev;
589586

590587
idxd_cdev = wq->idxd_cdev;
591588
wq->idxd_cdev = NULL;
592589
cdev_device_del(&idxd_cdev->cdev, cdev_dev(idxd_cdev));
590+
591+
cdev_ctx = &ictx[wq->idxd->data->type];
592+
ida_free(&cdev_ctx->minor_ida, idxd_cdev->minor);
593593
put_device(cdev_dev(idxd_cdev));
594594
}
595595

0 commit comments

Comments
 (0)