KVM: PPC: Book3S PR: return appropriate error when allocation fails
authorThadeu Lima de Souza Cascardo <cascardo@linux.vnet.ibm.com>
Wed, 17 Jul 2013 15:10:29 +0000 (12:10 -0300)
committerAlexander Graf <agraf@suse.de>
Wed, 28 Aug 2013 14:26:33 +0000 (16:26 +0200)
err was overwritten by a previous function call, and checked to be 0. If
the following page allocation fails, 0 is going to be returned instead
of -ENOMEM.

Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@linux.vnet.ibm.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
arch/powerpc/kvm/book3s_pr.c

index ddfaf560e5037e928cd521c8403cfc9d74bd5ff6..19cbac6f9d0345eef472e9f75f608b24eaedbf2a 100644 (file)
@@ -1047,11 +1047,12 @@ struct kvm_vcpu *kvmppc_core_vcpu_create(struct kvm *kvm, unsigned int id)
        if (err)
                goto free_shadow_vcpu;
 
+       err = -ENOMEM;
        p = __get_free_page(GFP_KERNEL|__GFP_ZERO);
-       /* the real shared page fills the last 4k of our page */
-       vcpu->arch.shared = (void*)(p + PAGE_SIZE - 4096);
        if (!p)
                goto uninit_vcpu;
+       /* the real shared page fills the last 4k of our page */
+       vcpu->arch.shared = (void *)(p + PAGE_SIZE - 4096);
 
 #ifdef CONFIG_PPC_BOOK3S_64
        /* default to book3s_64 (970fx) */