[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 2/7] vfio-ccw: Refactor cleanup of regions
From: |
Cornelia Huck |
Subject: |
[PULL 2/7] vfio-ccw: Refactor cleanup of regions |
Date: |
Thu, 18 Jun 2020 17:38:49 +0200 |
From: Eric Farman <farman@linux.ibm.com>
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 <farman@linux.ibm.com>
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
Message-Id: <20200505125757.98209-3-farman@linux.ibm.com>
Signed-off-by: Cornelia Huck <cohuck@redhat.com>
---
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 63406184d226..ca06213d0375 100644
--- a/hw/vfio/ccw.c
+++ b/hw/vfio/ccw.c
@@ -363,8 +363,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;
@@ -377,15 +376,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.25.4
- [PULL 0/7] s390x update, Cornelia Huck, 2020/06/18
- [PULL 2/7] vfio-ccw: Refactor cleanup of regions,
Cornelia Huck <=
- [PULL 3/7] vfio-ccw: Add support for the schib region, Cornelia Huck, 2020/06/18
- [PULL 1/7] Linux headers: update, Cornelia Huck, 2020/06/18
- [PULL 4/7] vfio-ccw: Refactor ccw irq handler, Cornelia Huck, 2020/06/18
- [PULL 5/7] s390x/css: Refactor the css_queue_crw() routine, Cornelia Huck, 2020/06/18
- [PULL 6/7] vfio-ccw: Add support for the CRW region and IRQ, Cornelia Huck, 2020/06/18
- [PULL 7/7] docs/s390x: fix vfio-ap device_del description, Cornelia Huck, 2020/06/18
- Re: [PULL 0/7] s390x update, no-reply, 2020/06/18
- Re: [PULL 0/7] s390x update, Peter Maydell, 2020/06/19