]> xenbits.xensource.com Git - libvirt.git/commitdiff
parallels: Avoid possible leak of "cpu" from parallelsBuildCapabilities
authorPeter Krempa <pkrempa@redhat.com>
Mon, 9 Jun 2014 07:36:30 +0000 (09:36 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Mon, 9 Jun 2014 07:49:56 +0000 (09:49 +0200)
4d06af97d38c3648937eb8f732704379b3cd9e59 introduced a possible memory
leak of the memory allocated into the "cpu" pointer in
parallelsBuildCapabilities in the case "nodeGetInfo()" would fail right
after the allocation. Rearrange the code to avoid the possibility of the
leak.

Found by Coverity.

src/parallels/parallels_driver.c

index 153961b38990490b9c20478f166536eec725926c..411527c03fbcb1322eb2bb2f53ce612b6a13afbd 100644 (file)
@@ -151,10 +151,10 @@ parallelsBuildCapabilities(void)
                                       "parallels", NULL, NULL, 0, NULL) == NULL)
         goto error;
 
-    if (VIR_ALLOC(cpu) < 0)
+    if (nodeGetInfo(&nodeinfo))
         goto error;
 
-    if (nodeGetInfo(&nodeinfo))
+    if (VIR_ALLOC(cpu) < 0)
         goto error;
 
     cpu->arch = caps->host.arch;