Skip to content

Commit

Permalink
[PATCH] kvm: fix vcpu freeing bug
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Ingo Molnar authored and Linus Torvalds committed Feb 12, 2007
1 parent 8cd1330 commit 1e8ba6f
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion drivers/kvm/kvm_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 1e8ba6f

Please sign in to comment.