diff mbox

KVM: only set kvm->arch.vioapic when success to init ioapic

Message ID 4B6FDB2D.9080707@cn.fujitsu.com (mailing list archive)
State New, archived
Headers show

Commit Message

Wei Yongjun Feb. 8, 2010, 9:36 a.m. UTC
None
diff mbox

Patch

diff --git a/virt/kvm/ioapic.c b/virt/kvm/ioapic.c
index a2edfd1..e13f529 100644
--- a/virt/kvm/ioapic.c
+++ b/virt/kvm/ioapic.c
@@ -386,7 +386,6 @@  int kvm_ioapic_init(struct kvm *kvm)
 	if (!ioapic)
 		return -ENOMEM;
 	mutex_init(&ioapic->lock);
-	kvm->arch.vioapic = ioapic;
 	kvm_ioapic_reset(ioapic);
 	kvm_iodevice_init(&ioapic->dev, &ioapic_mmio_ops);
 	ioapic->kvm = kvm;
@@ -395,6 +394,8 @@  int kvm_ioapic_init(struct kvm *kvm)
 	mutex_unlock(&kvm->slots_lock);
 	if (ret < 0)
 		kfree(ioapic);
+	else
+		kvm->arch.vioapic = ioapic;
 
 	return ret;
 }