Skip to content

Commit

Permalink
KVM: PPC: e500: Fix some NULL dereferences on error
Browse files Browse the repository at this point in the history
There are some error paths in kvmppc_core_vcpu_create_e500() where we
forget to set the error code.  It means that we return ERR_PTR(0) which
is NULL and 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 712b12d commit 73e77c0
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions arch/powerpc/kvm/e500.c
Original file line number Diff line number Diff line change
Expand Up @@ -455,16 +455,20 @@ static struct kvm_vcpu *kvmppc_core_vcpu_create_e500(struct kvm *kvm,
if (err)
goto free_vcpu;

if (kvmppc_e500_id_table_alloc(vcpu_e500) == NULL)
if (kvmppc_e500_id_table_alloc(vcpu_e500) == NULL) {
err = -ENOMEM;
goto uninit_vcpu;
}

err = kvmppc_e500_tlb_init(vcpu_e500);
if (err)
goto uninit_id;

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 73e77c0

Please sign in to comment.