]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
Fix crash on OOM in qemuDomainCCWAddressSetCreate()
authorDaniel P. Berrange <berrange@redhat.com>
Mon, 23 Sep 2013 13:10:35 +0000 (14:10 +0100)
committerDaniel P. Berrange <berrange@redhat.com>
Tue, 24 Sep 2013 09:52:21 +0000 (10:52 +0100)
If OOM occurs in qemuDomainCCWAddressSetCreate, it jumps to
a cleanup block and frees the partially initialized object.
It then mistakenly returns the address of the just free'd
pointer instead of NULL.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
src/qemu/qemu_command.c

index e6239c993cd6c084a5ff13f9815f8635a33e8e98..e98aed56010814da75c2711394313b29b50f322d 100644 (file)
@@ -1261,10 +1261,10 @@ qemuDomainCCWAddressSetCreate(void)
      qemuDomainCCWAddressSetPtr addrs = NULL;
 
     if (VIR_ALLOC(addrs) < 0)
-        goto cleanup;
+        goto error;
 
     if (!(addrs->defined = virHashCreate(10, qemuDomainCCWAddressSetFreeEntry)))
-        goto cleanup;
+        goto error;
 
     /* must use cssid = 0xfe (254) for virtio-ccw devices */
     addrs->next.cssid = 254;
@@ -1273,9 +1273,9 @@ qemuDomainCCWAddressSetCreate(void)
     addrs->next.assigned = 0;
     return addrs;
 
-cleanup:
+error:
     qemuDomainCCWAddressSetFree(addrs);
-    return addrs;
+    return NULL;
 }
 
 /*