]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
storage: Fix a resource leak in storageVolCreateXML
authorJohn Ferlan <jferlan@redhat.com>
Thu, 8 Oct 2015 20:24:47 +0000 (16:24 -0400)
committerJohn Ferlan <jferlan@redhat.com>
Tue, 13 Oct 2015 22:03:55 +0000 (18:03 -0400)
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@redhat.com>
src/storage/storage_driver.c

index 0a7ebcc1c07ebd202bdfd8ed50a586b6fd713803..0aa2d6e2695a7f32c9855b675a966076fb98c686 100644 (file)
@@ -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;