]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/commitdiff
[PATCH] kvm: fix vcpu freeing bug
authorIngo Molnar <mingo@elte.hu>
Mon, 12 Feb 2007 08:54:42 +0000 (00:54 -0800)
committerLinus Torvalds <torvalds@woody.linux-foundation.org>
Mon, 12 Feb 2007 17:48:40 +0000 (09:48 -0800)
vcpu_load() can return NULL and it sometimes does in failure paths (for
example when the userspace ABI version is too old) - causing a preemption
count underflow in the ->vcpu_free() later on.  So check for NULL.

Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
drivers/kvm/kvm_main.c

index eb3931ca680add4b8cfe2823e3145a7f8cd43877..9b79d3451f6f22700748c0ef26d79368995af6c0 100644 (file)
@@ -272,7 +272,9 @@ static void kvm_free_physmem(struct kvm *kvm)
 
 static void kvm_free_vcpu(struct kvm_vcpu *vcpu)
 {
-       vcpu_load(vcpu->kvm, vcpu_slot(vcpu));
+       if (!vcpu_load(vcpu->kvm, vcpu_slot(vcpu)))
+               return;
+
        kvm_mmu_destroy(vcpu);
        vcpu_put(vcpu);
        kvm_arch_ops->vcpu_free(vcpu);