[libvirt] [PATCH 03/12] storage: Fix a resource leak in storageVolCreateXML

John Ferlan jferlan at redhat.com
Fri Oct 9 13:34:02 UTC 2015


Commit id '1b5685da' refactored the code to move buildvoldef inside
the buildVol conditional; however, the VIR_FREE of the memory was
left only when 'buildret' failed, thus we're leaking memory.

Signed-off-by: John Ferlan <jferlan at redhat.com>
---
 src/storage/storage_driver.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c
index ddf4405..1c8ab87 100644
--- a/src/storage/storage_driver.c
+++ b/src/storage/storage_driver.c
@@ -1859,6 +1859,8 @@ storageVolCreateXML(virStoragePoolPtr obj,
 
         buildret = backend->buildVol(obj->conn, pool, buildvoldef, flags);
 
+        VIR_FREE(buildvoldef);
+
         storageDriverLock();
         virStoragePoolObjLock(pool);
         storageDriverUnlock();
@@ -1867,7 +1869,6 @@ storageVolCreateXML(virStoragePoolPtr obj,
         pool->asyncjobs--;
 
         if (buildret < 0) {
-            VIR_FREE(buildvoldef);
             storageVolDeleteInternal(volobj, backend, pool, voldef,
                                      0, false);
             voldef = NULL;
-- 
2.1.0




More information about the libvir-list mailing list