KVM: PPC: Fix vcpu_create dereference before validity check.
authorMatt Evans <matt@ozlabs.org>
Tue, 6 Dec 2011 21:19:42 +0000 (21:19 +0000)
committerAvi Kivity <avi@redhat.com>
Mon, 5 Mar 2012 12:52:38 +0000 (14:52 +0200)
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>
Signed-off-by: Avi Kivity <avi@redhat.com>
arch/powerpc/kvm/powerpc.c

index 06e955b5837ebb1f462ee57e8f48820c0e91df7d..25171037a36cdb5455dcc484c968752da269a767 100644 (file)
@@ -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;
 }