Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1e8ba6fb authored by Ingo Molnar's avatar Ingo Molnar Committed by Linus Torvalds
Browse files

[PATCH] kvm: fix vcpu freeing bug



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: default avatarIngo Molnar <mingo@elte.hu>
Signed-off-by: default avatarAvi Kivity <avi@qumranet.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 8cd13307
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -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);