Skip to contentSkip to conversation

KVM: PPC: Book3S PR: return appropriate error when allocation fails

PATCH Applied Thadeu Lima de Souza Cascardo 2 participants 2 messages Jul 17, 2013 – Aug 28, 2013

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 KVM: PPC: Book3S PR: return appropriate error when allocation fails

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.

---
 arch/powerpc/kvm/book3s_pr.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)
arch/powerpc/kvm/book3s_pr.c +3 -2
index 19498a5..c6e13d9 100644
@@ -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) */
Signature · 1 line
1.7.1