Commit 175be7e5 authored by Fabiano Rosas's avatar Fabiano Rosas Committed by Michael Ellerman

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: default avatarFabiano Rosas <farosas@linux.ibm.com>
Reviewed-by: default avatarNicholas Piggin <npiggin@gmail.com>
Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20220125155735.1018683-4-farosas@linux.ibm.com
parent c5d0d77b
......@@ -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)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment