[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: [PATCH V4 04/43] vfio/pci: vfio_pci_put_device on failure
From: |
Duan, Zhenzhong |
Subject: |
RE: [PATCH V4 04/43] vfio/pci: vfio_pci_put_device on failure |
Date: |
Tue, 3 Jun 2025 10:40:13 +0000 |
>-----Original Message-----
>From: Steve Sistare <steven.sistare@oracle.com>
>Subject: [PATCH V4 04/43] vfio/pci: vfio_pci_put_device on failure
>
>If vfio_realize fails after vfio_device_attach, it should call
>vfio_device_detach during error recovery. If it fails after
>vfio_device_get_name, it should free vbasedev->name. If it fails
>after vfio_pci_config_setup, it should free vdev->msix.
>
>To fix all, call vfio_pci_put_device().
>
>Signed-off-by: Steve Sistare <steven.sistare@oracle.com>
>---
> hw/vfio/pci.c | 1 +
> 1 file changed, 1 insertion(+)
>
>diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
>index a1bfdfe..7d3b9ff 100644
>--- a/hw/vfio/pci.c
>+++ b/hw/vfio/pci.c
>@@ -3296,6 +3296,7 @@ out_teardown:
> vfio_bars_exit(vdev);
> error:
> error_prepend(errp, VFIO_MSG_PREFIX, vbasedev->name);
>+ vfio_pci_put_device(vdev);
Double free, vfio_pci_put_device() is also called in vfio_instance_finalize().
Early free of vdev->vbasedev.name will also break something, e.g.,
trace_vfio_region_finalize(region->vbasedev->name, region->nr);
> }
>
> static void vfio_instance_finalize(Object *obj)
>--
>1.8.3.1
- RE: [PATCH V4 04/43] vfio/pci: vfio_pci_put_device on failure,
Duan, Zhenzhong <=