dmaengine: idxd: Avoid unnecessary destruction of file_ida
authorFenghua Yu <fenghua.yu@intel.com>
Tue, 30 Jan 2024 01:39:54 +0000 (17:39 -0800)
committerVinod Koul <vkoul@kernel.org>
Sat, 4 May 2024 12:22:04 +0000 (17:52 +0530)
file_ida is allocated during cdev open and is freed accordingly
during cdev release. This sequence is guaranteed by driver file
operations. Therefore, there is no need to destroy an already empty
file_ida when the WQ cdev is removed.

Worse, ida_free() in cdev release may happen after destruction of
file_ida per WQ cdev. This can lead to accessing an id in file_ida
after it has been destroyed, resulting in a kernel panic.

Remove ida_destroy(&file_ida) to address these issues.

Fixes: e6fd6d7e5f0f ("dmaengine: idxd: add a device to represent the file opened")
Signed-off-by: Lijun Pan <lijun.pan@intel.com>
Signed-off-by: Fenghua Yu <fenghua.yu@intel.com>
Reviewed-by: Dave Jiang <dave.jiang@intel.com>
Link: https://lore.kernel.org/r/20240130013954.2024231-1-fenghua.yu@intel.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
drivers/dma/idxd/cdev.c

index a4b771781afcdfe9d025607cd03d18334cf6690f..27ddb00cc7a43bc9141cb24dc2e1a46c3189cd6a 100644 (file)
@@ -501,7 +501,6 @@ void idxd_wq_del_cdev(struct idxd_wq *wq)
        struct idxd_cdev *idxd_cdev;
 
        idxd_cdev = wq->idxd_cdev;
-       ida_destroy(&file_ida);
        wq->idxd_cdev = NULL;
        cdev_device_del(&idxd_cdev->cdev, cdev_dev(idxd_cdev));
        put_device(cdev_dev(idxd_cdev));