summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlper Ak <alperyasinak1@gmail.com>2025-12-25 18:13:49 +0300
committerAlex Williamson <alex@shazbot.org>2025-12-28 12:42:46 -0700
commitacf44a2361b8d6356b71a970ab016065b5123b0e (patch)
tree71e4271f4d7c7dddfdd522a8c57d0b06b0b0243c
parent665077d78dc7941ce6a330c02023a2b469cc8cc7 (diff)
downloadlinux-acf44a2361b8d6356b71a970ab016065b5123b0e.tar.gz
linux-acf44a2361b8d6356b71a970ab016065b5123b0e.tar.bz2
linux-acf44a2361b8d6356b71a970ab016065b5123b0e.zip
vfio/xe: Fix use-after-free in xe_vfio_pci_alloc_file()
migf->filp is accessed after migf has been freed. Save the error value before calling kfree() to prevent use-after-free. Fixes: 1f5556ec8b9e ("vfio/xe: Add device specific vfio_pci driver variant for Intel graphics") Signed-off-by: Alper Ak <alperyasinak1@gmail.com> Link: https://lore.kernel.org/r/20251225151349.360870-1-alperyasinak1@gmail.com Signed-off-by: Alex Williamson <alex@shazbot.org>
-rw-r--r--drivers/vfio/pci/xe/main.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/drivers/vfio/pci/xe/main.c b/drivers/vfio/pci/xe/main.c
index 719ab4660085..2a5eb9260ec7 100644
--- a/drivers/vfio/pci/xe/main.c
+++ b/drivers/vfio/pci/xe/main.c
@@ -250,6 +250,7 @@ xe_vfio_pci_alloc_file(struct xe_vfio_pci_core_device *xe_vdev,
struct xe_vfio_pci_migration_file *migf;
const struct file_operations *fops;
int flags;
+ int ret;
migf = kzalloc(sizeof(*migf), GFP_KERNEL_ACCOUNT);
if (!migf)
@@ -259,8 +260,9 @@ xe_vfio_pci_alloc_file(struct xe_vfio_pci_core_device *xe_vdev,
flags = type == XE_VFIO_FILE_SAVE ? O_RDONLY : O_WRONLY;
migf->filp = anon_inode_getfile("xe_vfio_mig", fops, migf, flags);
if (IS_ERR(migf->filp)) {
+ ret = PTR_ERR(migf->filp);
kfree(migf);
- return ERR_CAST(migf->filp);
+ return ERR_PTR(ret);
}
mutex_init(&migf->lock);