]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemudDomainSetVcpus: avoid NULL-deref
authorJim Meyering <meyering@redhat.com>
Fri, 14 May 2010 10:38:43 +0000 (12:38 +0200)
committerJim Meyering <meyering@redhat.com>
Sat, 15 May 2010 07:02:54 +0000 (09:02 +0200)
* src/qemu/qemu_driver.c (qemudDomainSetVcpus): Avoid NULL-deref
upon unknown UUID.  Call qemuDomainObjBeginJob(vm) only after
ensuring that vm != NULL, not before.  This potential NULL-deref
was introduced by commit 2c555d87b0041e0d1ec4742386d2161d1b2f0600.

src/qemu/qemu_driver.c

index 4faa291eef7b643d89ef7d1c3369d42e2af76dc0..8f69b5ab64b8510c296470356c7ba0edfeb89d51 100644 (file)
@@ -5498,9 +5498,6 @@ static int qemudDomainSetVcpus(virDomainPtr dom, unsigned int nvcpus) {
     vm = virDomainFindByUUID(&driver->domains, dom->uuid);
     qemuDriverUnlock(driver);
 
-    if (qemuDomainObjBeginJob(vm) < 0)
-        goto cleanup;
-
     if (!vm) {
         char uuidstr[VIR_UUID_STRING_BUFLEN];
         virUUIDFormat(dom->uuid, uuidstr);
@@ -5509,6 +5506,9 @@ static int qemudDomainSetVcpus(virDomainPtr dom, unsigned int nvcpus) {
         goto endjob;
     }
 
+    if (qemuDomainObjBeginJob(vm) < 0)
+        goto cleanup;
+
     if (!virDomainObjIsActive(vm)) {
         qemuReportError(VIR_ERR_OPERATION_INVALID,
                          "%s", _("domain is not running"));