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
This commit is contained in:
Fabiano Rosas 2022-01-25 12:57:34 -03:00 committed by Michael Ellerman
parent c5d0d77b45
commit 175be7e580

View File

@ -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)