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 2c555d87b0.
This commit is contained in:
Jim Meyering 2010-05-14 12:38:43 +02:00
parent 39b3845fd7
commit b48fb801dd

View 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"));