[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 14/16] vfio/pci: Use g_autofree for vfio_region_info pointer
From: |
Zhenzhong Duan |
Subject: |
[PATCH 14/16] vfio/pci: Use g_autofree for vfio_region_info pointer |
Date: |
Wed, 15 May 2024 16:20:39 +0800 |
Pointer opregion is freed after vfio_pci_igd_opregion_init().
Use 'g_autofree' to avoid the g_free() calls.
Signed-off-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
---
hw/vfio/pci.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
index ecfbb9619f..be87478716 100644
--- a/hw/vfio/pci.c
+++ b/hw/vfio/pci.c
@@ -3146,7 +3146,7 @@ static void vfio_realize(PCIDevice *pdev, Error **errp)
if (!vdev->igd_opregion &&
vdev->features & VFIO_FEATURE_ENABLE_IGD_OPREGION) {
- struct vfio_region_info *opregion;
+ g_autofree struct vfio_region_info *opregion = NULL;
if (vdev->pdev.qdev.hotplugged) {
error_setg(errp,
@@ -3165,7 +3165,6 @@ static void vfio_realize(PCIDevice *pdev, Error **errp)
}
ret = vfio_pci_igd_opregion_init(vdev, opregion, errp);
- g_free(opregion);
if (ret) {
goto out_teardown;
}
--
2.34.1
- [PATCH 11/16] vfio/pci: Make vfio_intx_enable() return bool, (continued)
- [PATCH 11/16] vfio/pci: Make vfio_intx_enable() return bool, Zhenzhong Duan, 2024/05/15
- [PATCH 10/16] vfio/pci: Make vfio_populate_device() return a bool, Zhenzhong Duan, 2024/05/15
- [PATCH 04/16] vfio/helpers: Make vfio_set_irq_signaling() return bool, Zhenzhong Duan, 2024/05/15
- [PATCH 12/16] vfio/pci: Make vfio_populate_vga() return bool, Zhenzhong Duan, 2024/05/15
- [PATCH 13/16] vfio/pci: Make capability related functions return bool, Zhenzhong Duan, 2024/05/15
- [PATCH 14/16] vfio/pci: Use g_autofree for vfio_region_info pointer,
Zhenzhong Duan <=
- [PATCH 16/16] vfio/pci-quirks: Make vfio_add_*_cap() return bool, Zhenzhong Duan, 2024/05/15
- [PATCH 15/16] vfio/pci-quirks: Make vfio_pci_igd_opregion_init() return bool, Zhenzhong Duan, 2024/05/15
- Re: [PATCH 00/16] VFIO: misc cleanups part2, Cédric Le Goater, 2024/05/16