Skip to content

Commit

Permalink
KVM: PPC: e500mc: Fix a NULL dereference
Browse files Browse the repository at this point in the history
We should set "err = -ENOMEM;", otherwise it means we're returning
ERR_PTR(0) which is NULL.  It results in a NULL pointer dereference in
the caller.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
  • Loading branch information
Dan Carpenter authored and Paul Mackerras committed Aug 31, 2017
1 parent 73e77c0 commit 50a1a25
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion arch/powerpc/kvm/e500mc.c
Original file line number Diff line number Diff line change
Expand Up @@ -331,8 +331,10 @@ static struct kvm_vcpu *kvmppc_core_vcpu_create_e500mc(struct kvm *kvm,
goto uninit_vcpu;

vcpu->arch.shared = (void *)__get_free_page(GFP_KERNEL | __GFP_ZERO);
if (!vcpu->arch.shared)
if (!vcpu->arch.shared) {
err = -ENOMEM;
goto uninit_tlb;
}

return vcpu;

Expand Down

0 comments on commit 50a1a25

Please sign in to comment.