Skip to content

Commit 33c388b

Browse files
weiyjMartin Schwidefsky
authored andcommitted
s390/zcrypt: fix possible memory leak in ap_module_init()
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>
1 parent ef4423c commit 33c388b

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

drivers/s390/crypto/ap_bus.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1819,7 +1819,8 @@ int __init ap_module_init(void)
18191819
if (ap_domain_index < -1 || ap_domain_index > max_domain_id) {
18201820
pr_warn("%d is not a valid cryptographic domain\n",
18211821
ap_domain_index);
1822-
return -EINVAL;
1822+
rc = -EINVAL;
1823+
goto out_free;
18231824
}
18241825
/* In resume callback we need to know if the user had set the domain.
18251826
* If so, we can not just reset it.
@@ -1892,6 +1893,7 @@ int __init ap_module_init(void)
18921893
unregister_reset_call(&ap_reset_call);
18931894
if (ap_using_interrupts())
18941895
unregister_adapter_interrupt(&ap_airq);
1896+
out_free:
18951897
kfree(ap_configuration);
18961898
return rc;
18971899
}

0 commit comments

Comments
 (0)