[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 03/27] vfio: move more cleanup into vfio_pci_put_device()
From: |
John Levon |
Subject: |
[PATCH 03/27] vfio: move more cleanup into vfio_pci_put_device() |
Date: |
Thu, 15 May 2025 16:43:48 +0100 |
All of the cleanup can be done in the same place, and vfio-user will
want to do the same.
Signed-off-by: John Levon <john.levon@nutanix.com>
---
hw/vfio/pci.c | 23 ++++++++++++-----------
1 file changed, 12 insertions(+), 11 deletions(-)
diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
index a1bfdfe375..d96b55f80c 100644
--- a/hw/vfio/pci.c
+++ b/hw/vfio/pci.c
@@ -2854,6 +2854,18 @@ static bool vfio_populate_device(VFIOPCIDevice *vdev,
Error **errp)
static void vfio_pci_put_device(VFIOPCIDevice *vdev)
{
+ vfio_display_finalize(vdev);
+ vfio_bars_finalize(vdev);
+ g_free(vdev->emulated_config_bits);
+ g_free(vdev->rom);
+ /*
+ * XXX Leaking igd_opregion is not an oversight, we can't remove the
+ * fw_cfg entry therefore leaking this allocation seems like the safest
+ * option.
+ *
+ * g_free(vdev->igd_opregion);
+ */
+
vfio_device_detach(&vdev->vbasedev);
g_free(vdev->vbasedev.name);
@@ -3302,17 +3314,6 @@ static void vfio_instance_finalize(Object *obj)
{
VFIOPCIDevice *vdev = VFIO_PCI_BASE(obj);
- vfio_display_finalize(vdev);
- vfio_bars_finalize(vdev);
- g_free(vdev->emulated_config_bits);
- g_free(vdev->rom);
- /*
- * XXX Leaking igd_opregion is not an oversight, we can't remove the
- * fw_cfg entry therefore leaking this allocation seems like the safest
- * option.
- *
- * g_free(vdev->igd_opregion);
- */
vfio_pci_put_device(vdev);
}
--
2.43.0
- [PATCH 00/27] vfio-user client, John Levon, 2025/05/15
- [PATCH 01/27] vfio: return mr from vfio_get_xlat_addr, John Levon, 2025/05/15
- [PATCH 04/27] vfio: move config space read into vfio_pci_config_setup(), John Levon, 2025/05/15
- [PATCH 07/27] vfio: add per-region fd support, John Levon, 2025/05/15
- [PATCH 08/27] vfio: mark posted writes in region write callbacks, John Levon, 2025/05/15
- [PATCH 02/27] vfio/container: pass MemoryRegion to DMA operations, John Levon, 2025/05/15
- [PATCH 03/27] vfio: move more cleanup into vfio_pci_put_device(),
John Levon <=
- [PATCH 06/27] vfio: enable per-IRQ MSI-X masking, John Levon, 2025/05/15
- [PATCH 22/27] vfio-user: implement VFIO_USER_DMA_MAP/UNMAP, John Levon, 2025/05/15
- [PATCH 19/27] vfio-user: forward MSI-X PBA BAR accesses to server, John Levon, 2025/05/15
- [PATCH 05/27] vfio: refactor out IRQ signalling setup, John Levon, 2025/05/15
- [PATCH 24/27] vfio-user: add 'x-msg-timeout' option, John Levon, 2025/05/15
- [PATCH 14/27] vfio-user: implement VFIO_USER_DEVICE_GET_INFO, John Levon, 2025/05/15
- [PATCH 13/27] vfio-user: implement message send infrastructure, John Levon, 2025/05/15
- [PATCH 10/27] vfio-user: add vfio-user class and container, John Levon, 2025/05/15