linux/drivers/dma/idxd
Purva Yeshi 141054adba dmaengine: idxd: cdev: Fix uninitialized use of sva in idxd_cdev_open
[ Upstream commit 97994333de ]

Fix Smatch-detected issue:
drivers/dma/idxd/cdev.c:321 idxd_cdev_open() error:
uninitialized symbol 'sva'.

'sva' pointer may be used uninitialized in error handling paths.
Specifically, if PASID support is enabled and iommu_sva_bind_device()
returns an error, the code jumps to the cleanup label and attempts to
call iommu_sva_unbind_device(sva) without ensuring that sva was
successfully assigned. This triggers a Smatch warning about an
uninitialized symbol.

Initialize sva to NULL at declaration and add a check using
IS_ERR_OR_NULL() before unbinding the device. This ensures the
function does not use an invalid or uninitialized pointer during
cleanup.

Signed-off-by: Purva Yeshi <purvayeshi550@gmail.com>
Reviewed-by: Dave Jiang <dave.jiang@intel.com>
Acked-by: Vinicius Costa Gomes <vinicius.gomes@intel.com>
Link: https://lore.kernel.org/r/20250410110216.21592-1-purvayeshi550@gmail.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
History 2025-06-04 14:43:52 +02:00
..
bus.c driver core: have match() callback in struct bus_type take a const * 2024-07-03 15:16:54 +02:00
cdev.c dmaengine: idxd: cdev: Fix uninitialized use of sva in idxd_cdev_open 2025-06-04 14:43:52 +02:00
compat.c driver core: make [device_]driver_attach take a const * 2024-06-20 12:51:42 +02:00
debugfs.c dmaengine: idxd: Convert spinlock to mutex to lock evl workqueue 2024-04-07 13:31:44 +05:30
defaults.c dmaengine: idxd: Add support for device/wq defaults 2023-12-15 17:52:53 +08:00
device.c dmaengine: idxd: Convert spinlock to mutex to lock evl workqueue 2024-04-07 13:31:44 +05:30
dma.c dmaengine: add channel device name to channel registration 2024-06-11 23:55:34 +05:30
idxd.h dmaengine: idxd: Clean up cpumask and hotplug for perfmon 2024-09-10 11:44:13 +02:00
init.c dmaengine: idxd: Refactor remove call with idxd_cleanup() helper 2025-05-22 14:29:52 +02:00
irq.c dmaengine: idxd: Fix possible Use-After-Free in irq_process_work_list 2024-06-11 21:37:25 +05:30
Makefile module: Convert default symbol namespace to string literal 2025-02-08 09:57:05 +01:00
perfmon.c dmaengine updates for v6.12 2024-09-23 14:08:08 -07:00
perfmon.h dmaengine: idxd: Add IDXD performance monitor support 2021-04-25 21:46:12 +05:30
registers.h VFIO: Add the SPR_DSA and SPR_IAX devices to the denylist 2024-05-13 14:07:33 +00:00
submit.c dmaengine: Fix spelling mistakes 2024-09-02 13:56:01 +05:30
sysfs.c dmaengine: idxd: add a write() method for applications to submit work 2024-05-13 14:07:45 +00:00