diff options
author | Fabiano Rosas <farosas@linux.ibm.com> | 2022-01-25 16:57:34 +0100 |
---|---|---|
committer | Michael Ellerman <mpe@ellerman.id.au> | 2022-02-03 06:50:44 +0100 |
commit | 175be7e5800e2782a7e38ee9e1b64633494c4b44 (patch) | |
tree | 0f11ef9156f1605cf6a3802e502dccd9e0ec7124 /arch/powerpc/kvm | |
parent | KVM: PPC: Book3S HV: Delay setting of kvm ops (diff) | |
download | linux-175be7e5800e2782a7e38ee9e1b64633494c4b44.tar.xz linux-175be7e5800e2782a7e38ee9e1b64633494c4b44.zip |
KVM: PPC: Book3S HV: Free allocated memory if module init fails
The module's exit function is not called when the init fails, we need
to do cleanup before returning.
Signed-off-by: Fabiano Rosas <farosas@linux.ibm.com>
Reviewed-by: Nicholas Piggin <npiggin@gmail.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20220125155735.1018683-4-farosas@linux.ibm.com
Diffstat (limited to 'arch/powerpc/kvm')
-rw-r--r-- | arch/powerpc/kvm/book3s_hv.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c index ec56970175e2..c886557638a1 100644 --- a/arch/powerpc/kvm/book3s_hv.c +++ b/arch/powerpc/kvm/book3s_hv.c @@ -6096,7 +6096,7 @@ static int kvmppc_book3s_init_hv(void) if (!cpu_has_feature(CPU_FTR_ARCH_300)) { r = kvm_init_subcore_bitmap(); if (r) - return r; + goto err; } /* @@ -6112,7 +6112,8 @@ static int kvmppc_book3s_init_hv(void) np = of_find_compatible_node(NULL, NULL, "ibm,opal-intc"); if (!np) { pr_err("KVM-HV: Cannot determine method for accessing XICS\n"); - return -ENODEV; + r = -ENODEV; + goto err; } /* presence of intc confirmed - node can be dropped again */ of_node_put(np); @@ -6125,12 +6126,12 @@ static int kvmppc_book3s_init_hv(void) r = kvmppc_mmu_hv_init(); if (r) - return r; + goto err; if (kvmppc_radix_possible()) { r = kvmppc_radix_init(); if (r) - return r; + goto err; } r = kvmppc_uvmem_init(); @@ -6143,6 +6144,12 @@ static int kvmppc_book3s_init_hv(void) kvmppc_hv_ops = &kvm_ops_hv; return 0; + +err: + kvmhv_nested_exit(); + kvmppc_radix_exit(); + + return r; } static void kvmppc_book3s_exit_hv(void) |