]> xenbits.xensource.com Git - libvirt.git/commitdiff
conf: avoid memory leak on disk operations
authorEric Blake <eblake@redhat.com>
Tue, 2 Aug 2011 19:48:43 +0000 (13:48 -0600)
committerEric Blake <eblake@redhat.com>
Tue, 2 Aug 2011 21:05:39 +0000 (15:05 -0600)
Detected by Coverity.  Leak on meta introduced in commit 85aa40e.

* src/conf/domain_conf.c (virDomainDiskDefForeachPath): Plug leak.

src/conf/domain_conf.c

index e182cd615942d6ba331f3e8485d78d493281bde0..010ce571c02fa9f460c2e93603d3ad1bd3f20b9d 100644 (file)
@@ -11315,7 +11315,7 @@ int virDomainDiskDefForeachPath(virDomainDiskDefPtr disk,
                                 virDomainDiskDefPathIterator iter,
                                 void *opaque)
 {
-    virHashTablePtr paths;
+    virHashTablePtr paths = NULL;
     int format;
     int ret = -1;
     size_t depth = 0;
@@ -11339,7 +11339,7 @@ int virDomainDiskDefForeachPath(virDomainDiskDefPtr disk,
             virDomainReportError(VIR_ERR_INTERNAL_ERROR,
                                  _("unknown disk format '%s' for %s"),
                                  disk->driverType, disk->src);
-            return -1;
+            goto cleanup;
         }
     } else {
         if (allowProbing) {
@@ -11348,7 +11348,7 @@ int virDomainDiskDefForeachPath(virDomainDiskDefPtr disk,
             virDomainReportError(VIR_ERR_INTERNAL_ERROR,
                                  _("no disk format for %s and probing is disabled"),
                                  disk->src);
-            return -1;
+            goto cleanup;
         }
     }