From: John Ferlan Date: Thu, 8 Oct 2015 20:24:47 +0000 (-0400) Subject: storage: Fix a resource leak in storageVolCreateXML X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=27d2d99fe75299cccaf121db140b2913dc630b96;p=people%2Fliuw%2Flibxenctrl-split%2Flibvirt.git storage: Fix a resource leak in storageVolCreateXML 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 --- diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c index 0a7ebcc1c..0aa2d6e26 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;