Patchwork [40/52] KVM: PPC: Fix vcpu_create dereference before validity check.

login
register
mail settings
Submitter Alexander Graf
Date Jan. 13, 2012, 2:31 p.m.
Message ID <1326465115-5976-41-git-send-email-agraf@suse.de>
Download mbox | patch
Permalink /patch/135874/
State New
Headers show

Comments

Alexander Graf - Jan. 13, 2012, 2:31 p.m.
From: Matt Evans <matt@ozlabs.org>

Fix usage of vcpu struct before check that it's actually valid.

Signed-off-by: Matt Evans <matt@ozlabs.org>
Signed-off-by: Alexander Graf <agraf@suse.de>
---
 arch/powerpc/kvm/powerpc.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

Patch

diff --git a/arch/powerpc/kvm/powerpc.c b/arch/powerpc/kvm/powerpc.c
index 06e955b..2517103 100644
--- a/arch/powerpc/kvm/powerpc.c
+++ b/arch/powerpc/kvm/powerpc.c
@@ -289,9 +289,10 @@  struct kvm_vcpu *kvm_arch_vcpu_create(struct kvm *kvm, unsigned int id)
 {
 	struct kvm_vcpu *vcpu;
 	vcpu = kvmppc_core_vcpu_create(kvm, id);
-	vcpu->arch.wqp = &vcpu->wq;
-	if (!IS_ERR(vcpu))
+	if (!IS_ERR(vcpu)) {
+		vcpu->arch.wqp = &vcpu->wq;
 		kvmppc_create_vcpu_debugfs(vcpu, id);
+	}
 	return vcpu;
 }