[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RFC PATCH v2 3/7] vfio-ccw: Refactor cleanup of regions
From: |
Eric Farman |
Subject: |
[RFC PATCH v2 3/7] vfio-ccw: Refactor cleanup of regions |
Date: |
Thu, 6 Feb 2020 22:45:05 +0100 |
While we're at it, add a g_free() for the async_cmd_region that
is the last thing currently created. g_free() knows how to handle
NULL pointers, so this makes it easier to remember what cleanups
need to be performed when new regions are added.
Signed-off-by: Eric Farman <address@hidden>
Reviewed-by: Cornelia Huck <address@hidden>
---
Notes:
v1-v2:
- Add Conny's r-b
hw/vfio/ccw.c | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/hw/vfio/ccw.c b/hw/vfio/ccw.c
index 19144ecfc7..26e479c53f 100644
--- a/hw/vfio/ccw.c
+++ b/hw/vfio/ccw.c
@@ -371,8 +371,7 @@ static void vfio_ccw_get_region(VFIOCCWDevice *vcdev, Error
**errp)
vcdev->io_region_size = info->size;
if (sizeof(*vcdev->io_region) != vcdev->io_region_size) {
error_setg(errp, "vfio: Unexpected size of the I/O region");
- g_free(info);
- return;
+ goto out_err;
}
vcdev->io_region_offset = info->offset;
@@ -385,15 +384,20 @@ static void vfio_ccw_get_region(VFIOCCWDevice *vcdev,
Error **errp)
vcdev->async_cmd_region_size = info->size;
if (sizeof(*vcdev->async_cmd_region) != vcdev->async_cmd_region_size) {
error_setg(errp, "vfio: Unexpected size of the async cmd region");
- g_free(vcdev->io_region);
- g_free(info);
- return;
+ goto out_err;
}
vcdev->async_cmd_region_offset = info->offset;
vcdev->async_cmd_region = g_malloc0(info->size);
}
g_free(info);
+ return;
+
+out_err:
+ g_free(vcdev->async_cmd_region);
+ g_free(vcdev->io_region);
+ g_free(info);
+ return;
}
static void vfio_ccw_put_region(VFIOCCWDevice *vcdev)
--
2.17.1
- [RFC PATCH v2 0/7] s390x/vfio_ccw: Channel Path Handling [QEMU], Eric Farman, 2020/02/06
- [RFC PATCH v2 2/7] linux-headers: update, Eric Farman, 2020/02/06
- [RFC PATCH v2 5/7] vfio-ccw: Add support for the crw region, Eric Farman, 2020/02/06
- [RFC PATCH v2 3/7] vfio-ccw: Refactor cleanup of regions,
Eric Farman <=
- [RFC PATCH v2 1/7] vfio-ccw: Return IOINST_CC_NOT_OPERATIONAL for EIO, Eric Farman, 2020/02/06
- [RFC PATCH v2 7/7] vfio-ccw: Add support for the CRW irq, Eric Farman, 2020/02/06
- [RFC PATCH v2 6/7] vfio-ccw: Refactor ccw irq handler, Eric Farman, 2020/02/06
- [RFC PATCH v2 4/7] vfio-ccw: Add support for the schib region, Eric Farman, 2020/02/06