[libvirt] [PATCH 3/3] storage: do not leak storage pool XML filename

Michael Chapman mike at very.puzzling.org
Thu Dec 31 06:04:40 UTC 2015


Valgrind complained:

==28277== 38 bytes in 1 blocks are definitely lost in loss record 298 of 957
==28277==    at 0x4A06A2E: malloc (vg_replace_malloc.c:270)
==28277==    by 0x82D7F57: __vasprintf_chk (in /lib64/libc-2.12.so)
==28277==    by 0x52EF16A: virVasprintfInternal (stdio2.h:199)
==28277==    by 0x52EF25C: virAsprintfInternal (virstring.c:514)
==28277==    by 0x52B1FA9: virFileBuildPath (virfile.c:2831)
==28277==    by 0x19B1947C: storageDriverAutostart (storage_driver.c:191)
==28277==    by 0x19B196A7: storageStateAutoStart (storage_driver.c:307)
==28277==    by 0x538527E: virStateInitialize (libvirt.c:793)
==28277==    by 0x11D7CF: daemonRunStateInit (libvirtd.c:947)
==28277==    by 0x52F4694: virThreadHelper (virthread.c:206)
==28277==    by 0x6E08A50: start_thread (in /lib64/libpthread-2.12.so)
==28277==    by 0x82BE93C: clone (in /lib64/libc-2.12.so)

Signed-off-by: Michael Chapman <mike at very.puzzling.org>
---
 src/storage/storage_driver.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c
index 0bb577f..c8f259e 100644
--- a/src/storage/storage_driver.c
+++ b/src/storage/storage_driver.c
@@ -151,7 +151,6 @@ static void
 storageDriverAutostart(void)
 {
     size_t i;
-    char *stateFile = NULL;
     virConnectPtr conn = NULL;
 
     /* XXX Remove hardcoding of QEMU URI */
@@ -187,6 +186,8 @@ storageDriverAutostart(void)
         }
 
         if (started) {
+            char *stateFile;
+
             virStoragePoolObjClearVols(pool);
             stateFile = virFileBuildPath(driver->stateDir,
                                          pool->def->name, ".xml");
@@ -201,11 +202,10 @@ storageDriverAutostart(void)
                 VIR_ERROR(_("Failed to autostart storage pool '%s': %s"),
                           pool->def->name, err ? err->message :
                           _("no error message found"));
-                VIR_FREE(stateFile);
-                virStoragePoolObjUnlock(pool);
-                continue;
+            } else {
+                pool->active = true;
             }
-            pool->active = true;
+            VIR_FREE(stateFile);
         }
         virStoragePoolObjUnlock(pool);
     }
-- 
2.4.3




More information about the libvir-list mailing list