s390/zcrypt: fix possible memory leak in ap_module_init()
authorWei Yongjun <weiyj.lk@gmail.com>
Sun, 31 Jul 2016 09:47:06 +0000 (11:47 +0200)
committerMartin Schwidefsky <schwidefsky@de.ibm.com>
Sun, 31 Jul 2016 10:10:41 +0000 (06:10 -0400)
ap_configuration is malloced in ap_module_init() and should be freed
before leaving from the error handling cases, otherwise it may cause
memory leak.

Signed-off-by: Wei Yongjun <weiyj.lk@gmail.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
drivers/s390/crypto/ap_bus.c

index 03e4d6246d87975515802f8ce798e82a9db7e81b..ed92fb09fc8ed9266f3a056780dfbf4e5c9908d9 100644 (file)
@@ -1819,7 +1819,8 @@ int __init ap_module_init(void)
        if (ap_domain_index < -1 || ap_domain_index > max_domain_id) {
                pr_warn("%d is not a valid cryptographic domain\n",
                        ap_domain_index);
-               return -EINVAL;
+               rc = -EINVAL;
+               goto out_free;
        }
        /* In resume callback we need to know if the user had set the domain.
         * If so, we can not just reset it.
@@ -1892,6 +1893,7 @@ out:
        unregister_reset_call(&ap_reset_call);
        if (ap_using_interrupts())
                unregister_adapter_interrupt(&ap_airq);
+out_free:
        kfree(ap_configuration);
        return rc;
 }
This page took 0.027898 seconds and 5 git commands to generate.