]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
dmaengine: idxd: Fix passing freed memory in idxd_cdev_open()
authorHarshit Mogalapalli <harshit.m.mogalapalli@oracle.com>
Tue, 9 May 2023 06:07:16 +0000 (23:07 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 4 Jun 2025 12:40:22 +0000 (14:40 +0200)
commitbc952bf4e07d0f15e77c6484b26e1d0058d6912f
treeb81d467cf9d8a7833a22856c96513d1ced925109
parent50026aa530a693a848827c6371a3cc9476fd299b
dmaengine: idxd: Fix passing freed memory in idxd_cdev_open()

commit 0642287e3ecdd0d1f88e6a2e63768e16153a990c upstream.

Smatch warns:
drivers/dma/idxd/cdev.c:327:
idxd_cdev_open() warn: 'sva' was already freed.

When idxd_wq_set_pasid() fails, the current code unbinds sva and then
goes to 'failed_set_pasid' where iommu_sva_unbind_device is called
again causing the above warning.
[ device_user_pasid_enabled(idxd) is still true when calling
failed_set_pasid ]

Fix this by removing additional unbind when idxd_wq_set_pasid() fails

Fixes: b022f59725f0 ("dmaengine: idxd: add idxd_copy_cr() to copy user completion record during page fault handling")
Signed-off-by: Harshit Mogalapalli <harshit.m.mogalapalli@oracle.com>
Acked-by: Fenghua Yu <fenghua.yu@intel.com>
Acked-by: Dave Jiang <dave.jiang@intel.com>
Link: https://lore.kernel.org/r/20230509060716.2830630-1-harshit.m.mogalapalli@oracle.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/dma/idxd/cdev.c