summaryrefslogtreecommitdiff
path: root/drivers/kvm
diff options
context:
space:
mode:
authorIngo Molnar <mingo@elte.hu>2007-02-12 00:54:42 -0800
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-02-12 09:48:40 -0800
commit1e8ba6fba5050ec11bba90c8622aa2ed95ff711f (patch)
tree4dfc7c1c8a6119648978f25c1065b344123638cb /drivers/kvm
parent8cd133073f9b5cd335c0b2e4740aceb025d50ca9 (diff)
downloadlinux-3.10-1e8ba6fba5050ec11bba90c8622aa2ed95ff711f.tar.gz
linux-3.10-1e8ba6fba5050ec11bba90c8622aa2ed95ff711f.tar.bz2
linux-3.10-1e8ba6fba5050ec11bba90c8622aa2ed95ff711f.zip
[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: 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>
Diffstat (limited to 'drivers/kvm')
-rw-r--r--drivers/kvm/kvm_main.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/drivers/kvm/kvm_main.c b/drivers/kvm/kvm_main.c
index eb3931ca680..9b79d3451f6 100644
--- a/drivers/kvm/kvm_main.c
+++ b/drivers/kvm/kvm_main.c
@@ -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);