]> xenbits.xensource.com Git - libvirt.git/commitdiff
storage: do not leak storage pool XML filename
authorMichael Chapman <mike@very.puzzling.org>
Thu, 31 Dec 2015 06:04:40 +0000 (17:04 +1100)
committerMichal Privoznik <mprivozn@redhat.com>
Mon, 4 Jan 2016 13:54:23 +0000 (14:54 +0100)
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@very.puzzling.org>
src/storage/storage_driver.c

index 0bb577fd7668f1f4e332a7a2ffeb02773bd8b75d..c8f259e317348284d2b0c1556d362dc875c5dd64 100644 (file)
@@ -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);
     }