mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
storage: Resolve resource leak using 'vol' buffer
This commit is contained in:
parent
b17409674e
commit
439b72ecf5
@ -1,6 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* storage_backend_rbd.c: storage backend for RBD (RADOS Block Device) handling
|
* storage_backend_rbd.c: storage backend for RBD (RADOS Block Device) handling
|
||||||
*
|
*
|
||||||
|
* Copyright (C) 2013 Red Hat, Inc.
|
||||||
* Copyright (C) 2012 Wido den Hollander
|
* Copyright (C) 2012 Wido den Hollander
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
@ -319,26 +320,31 @@ static int virStorageBackendRBDRefreshPool(virConnectPtr conn ATTRIBUTE_UNUSED,
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0, name = names; name < names + max_size; i++) {
|
for (i = 0, name = names; name < names + max_size; i++) {
|
||||||
|
virStorageVolDefPtr vol;
|
||||||
|
|
||||||
if (VIR_REALLOC_N(pool->volumes.objs, pool->volumes.count + 1) < 0) {
|
if (VIR_REALLOC_N(pool->volumes.objs, pool->volumes.count + 1) < 0) {
|
||||||
virStoragePoolObjClearVols(pool);
|
virStoragePoolObjClearVols(pool);
|
||||||
goto out_of_memory;
|
goto out_of_memory;
|
||||||
}
|
}
|
||||||
|
|
||||||
virStorageVolDefPtr vol;
|
if (STREQ(name, ""))
|
||||||
|
break;
|
||||||
|
|
||||||
if (VIR_ALLOC(vol) < 0)
|
if (VIR_ALLOC(vol) < 0)
|
||||||
goto out_of_memory;
|
goto out_of_memory;
|
||||||
|
|
||||||
vol->name = strdup(name);
|
vol->name = strdup(name);
|
||||||
if (vol->name == NULL)
|
if (vol->name == NULL) {
|
||||||
|
VIR_FREE(vol);
|
||||||
goto out_of_memory;
|
goto out_of_memory;
|
||||||
|
}
|
||||||
if (STREQ(vol->name, ""))
|
|
||||||
break;
|
|
||||||
|
|
||||||
name += strlen(name) + 1;
|
name += strlen(name) + 1;
|
||||||
|
|
||||||
if (volStorageBackendRBDRefreshVolInfo(vol, pool, ptr) < 0)
|
if (volStorageBackendRBDRefreshVolInfo(vol, pool, ptr) < 0) {
|
||||||
|
virStorageVolDefFree(vol);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
pool->volumes.objs[pool->volumes.count++] = vol;
|
pool->volumes.objs[pool->volumes.count++] = vol;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user