From: Jim Meyering Date: Fri, 14 May 2010 10:38:43 +0000 (+0200) Subject: qemudDomainSetVcpus: avoid NULL-deref X-Git-Tag: v0.8.2~280 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b48fb801dd33757b8b489f3adff8113b2a28cf9a;p=thirdparty%2Flibvirt.git qemudDomainSetVcpus: avoid NULL-deref * 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. --- diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 4faa291eef..8f69b5ab64 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -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"));