kvmppc_booke_init() allocates pages for the Book E exception
handlers. If the kvm_init() call fails, kvmppc_e500_init()
returns without freeing those pages. Free the pages on this
error path.

Fixes: bc8080cbcc88 ("KVM: ppc: E500 core-specific code")
Signed-off-by: Haoxiang Li <[email protected]>
---
 arch/powerpc/kvm/e500.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/kvm/e500.c b/arch/powerpc/kvm/e500.c
index c58a5a5fb64c..3df53e55765c 100644
--- a/arch/powerpc/kvm/e500.c
+++ b/arch/powerpc/kvm/e500.c
@@ -532,8 +532,11 @@ static int __init kvmppc_e500_init(void)
                           ivor[max_ivor] + handler_len);
 
        r = kvm_init(sizeof(struct kvmppc_vcpu_e500), 0, THIS_MODULE);
-       if (r)
+       if (r) {
+               free_pages(kvmppc_booke_handlers, VCPU_SIZE_ORDER);
                goto err_out;
+       }
+
        kvm_ops_e500.owner = THIS_MODULE;
        kvmppc_pr_ops = &kvm_ops_e500;
 
-- 
2.25.1


Reply via email to