diff options
author | Dan Carpenter <dan.carpenter@oracle.com> | 2017-07-13 09:38:29 +0200 |
---|---|---|
committer | Paul Mackerras <paulus@ozlabs.org> | 2017-08-31 04:36:44 +0200 |
commit | 73e77c0982fd25ddb536339906412cbed78d0b79 (patch) | |
tree | 47d28bea0d2da98c286e13486747cf64dd137044 | |
parent | kvm: nVMX: Validate the virtual-APIC address on nested VM-entry (diff) | |
download | linux-73e77c0982fd25ddb536339906412cbed78d0b79.tar.xz linux-73e77c0982fd25ddb536339906412cbed78d0b79.zip |
KVM: PPC: e500: Fix some NULL dereferences on error
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>
-rw-r--r-- | arch/powerpc/kvm/e500.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/arch/powerpc/kvm/e500.c b/arch/powerpc/kvm/e500.c index 32fdab57d604..f9f6468f4171 100644 --- a/arch/powerpc/kvm/e500.c +++ b/arch/powerpc/kvm/e500.c @@ -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; |