[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <7972e017-ec4a-4fe4-a11f-bc0a1ff9b6f7@intel.com>
Date: Wed, 6 Aug 2025 10:27:38 -0700
From: Dave Jiang <dave.jiang@...el.com>
To: Vinicius Costa Gomes <vinicius.gomes@...el.com>,
Vinod Koul <vkoul@...nel.org>, Dan Williams <dan.j.williams@...el.com>,
Fenghua Yu <fenghuay@...dia.com>
Cc: dmaengine@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 8/9] dmaengine: idxd: Fix freeing the allocated ida too
late
On 8/4/25 6:27 PM, Vinicius Costa Gomes wrote:
> 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: 04922b7445a1 ("dmaengine: idxd: fix cdev setup and free device lifetime issues")
> Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@...el.com>
Reviewed-by: Dave Jiang <dave.jiang@...el.com>
> ---
> drivers/dma/idxd/cdev.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/dma/idxd/cdev.c b/drivers/dma/idxd/cdev.c
> index 7e4715f927732702416d917f34ab0a83f575d533..4105688cf3f060704b851ee17467c135c170326e 100644
> --- a/drivers/dma/idxd/cdev.c
> +++ b/drivers/dma/idxd/cdev.c
> @@ -158,11 +158,7 @@ static const struct device_type idxd_cdev_file_type = {
> static void idxd_cdev_dev_release(struct device *dev)
> {
> struct idxd_cdev *idxd_cdev = dev_to_cdev(dev);
> - struct idxd_cdev_context *cdev_ctx;
> - struct idxd_wq *wq = idxd_cdev->wq;
>
> - cdev_ctx = &ictx[wq->idxd->data->type];
> - ida_free(&cdev_ctx->minor_ida, idxd_cdev->minor);
> kfree(idxd_cdev);
> }
>
> @@ -582,11 +578,15 @@ int idxd_wq_add_cdev(struct idxd_wq *wq)
>
> void idxd_wq_del_cdev(struct idxd_wq *wq)
> {
> + struct idxd_cdev_context *cdev_ctx;
> struct idxd_cdev *idxd_cdev;
>
> idxd_cdev = wq->idxd_cdev;
> wq->idxd_cdev = NULL;
> cdev_device_del(&idxd_cdev->cdev, cdev_dev(idxd_cdev));
> +
> + cdev_ctx = &ictx[wq->idxd->data->type];
> + ida_free(&cdev_ctx->minor_ida, idxd_cdev->minor);
> put_device(cdev_dev(idxd_cdev));
> }
>
>
Powered by blists - more mailing lists