Commit f699318b authored by Fenghua Yu's avatar Fenghua Yu Committed by Xiaochen Shen
Browse files

dmaengine: idxd: Avoid unnecessary destruction of file_ida

mainline inclusion
from mainline-v6.10-rc1
commit 76e43fa6a456787bad31b8d0daeabda27351a480
category: bugfix
bugzilla: https://gitee.com/openeuler/intel-kernel/issues/I9TA1S
CVE: NA

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=76e43fa6a456787bad31b8d0daeabda27351a480



--------------------------------

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.

Intel-SIG: commit 76e43fa6a456 dmaengine: idxd: Avoid unnecessary destruction of file_ida.
Incremental backporting patches for DSA/IAA on Intel Xeon platform.

Fixes: e6fd6d7e ("dmaengine: idxd: add a device to represent the file opened")
Signed-off-by: default avatarLijun Pan <lijun.pan@intel.com>
Signed-off-by: default avatarFenghua Yu <fenghua.yu@intel.com>
Reviewed-by: default avatarDave Jiang <dave.jiang@intel.com>
Link: https://lore.kernel.org/r/20240130013954.2024231-1-fenghua.yu@intel.com


Signed-off-by: default avatarVinod Koul <vkoul@kernel.org>
Signed-off-by: default avatarXiaochen Shen <xiaochen.shen@intel.com>
parent f54a0fb7
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -577,7 +577,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));