Skip to content

Commit 9ac74f0

Browse files
Wei YongjunAlexander Gordeev
authored andcommitted
s390/ap: fix memory leak in ap_init_qci_info()
If kzalloc() for 'ap_qci_info_old' failed, 'ap_qci_info' shold be freed before return. Otherwise it is a memory leak. Link: https://lore.kernel.org/r/20221114110830.542246-1-weiyongjun@huaweicloud.com Fixes: 2839158 ("s390/ap: notify drivers on config changed and scan complete callbacks") Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com> Signed-off-by: Harald Freudenberger <freude@linux.ibm.com> Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com>
1 parent e3c1102 commit 9ac74f0

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

drivers/s390/crypto/ap_bus.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,8 +233,11 @@ static void __init ap_init_qci_info(void)
233233
if (!ap_qci_info)
234234
return;
235235
ap_qci_info_old = kzalloc(sizeof(*ap_qci_info_old), GFP_KERNEL);
236-
if (!ap_qci_info_old)
236+
if (!ap_qci_info_old) {
237+
kfree(ap_qci_info);
238+
ap_qci_info = NULL;
237239
return;
240+
}
238241
if (ap_fetch_qci_info(ap_qci_info) != 0) {
239242
kfree(ap_qci_info);
240243
kfree(ap_qci_info_old);

0 commit comments

Comments
 (0)