mirror of
https://github.com/xen-project/xen.git
synced 2026-10-29 18:50:05 +01:00
libxl: do not leak front flexarray on error in libxl_create_pci_backend
Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
This commit is contained in:
1 parent
63f600a362
commit
382571fcde
1 file changed
+12
-7
+12
-7
@@ -224,17 +224,19 @@ parse_error:
|
||||
static int libxl_create_pci_backend(libxl__gc *gc, uint32_t domid, libxl_device_pci *pcidev, int num)
|
||||
{
|
||||
libxl_ctx *ctx = libxl__gc_owner(gc);
|
||||
flexarray_t *front;
|
||||
flexarray_t *back;
|
||||
flexarray_t *front = NULL;
|
||||
flexarray_t *back = NULL;
|
||||
libxl__device device;
|
||||
int i;
|
||||
int ret = ERROR_NOMEM, i;
|
||||
|
||||
front = flexarray_make(16, 1);
|
||||
if (!front)
|
||||
return ERROR_NOMEM;
|
||||
goto out;
|
||||
back = flexarray_make(16, 1);
|
||||
if (!back)
|
||||
return ERROR_NOMEM;
|
||||
goto out;
|
||||
|
||||
ret = 0;
|
||||
|
||||
LIBXL__LOG(ctx, LIBXL__LOG_DEBUG, "Creating pci backend");
|
||||
|
||||
@@ -271,8 +273,11 @@ static int libxl_create_pci_backend(libxl__gc *gc, uint32_t domid, libxl_device_
|
||||
libxl__xs_kvs_of_flexarray(gc, back, back->count),
|
||||
libxl__xs_kvs_of_flexarray(gc, front, front->count));
|
||||
|
||||
flexarray_free(back);
|
||||
flexarray_free(front);
|
||||
out:
|
||||
if (back)
|
||||
flexarray_free(back);
|
||||
if (front)
|
||||
flexarray_free(front);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||