Commit 9ac74f06 authored by Wei Yongjun's avatar Wei Yongjun Committed by Alexander Gordeev

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: 28391585 ("s390/ap: notify drivers on config changed and scan complete callbacks")
Signed-off-by: default avatarWei Yongjun <weiyongjun1@huawei.com>
Signed-off-by: default avatarHarald Freudenberger <freude@linux.ibm.com>
Signed-off-by: default avatarAlexander Gordeev <agordeev@linux.ibm.com>
parent e3c11025
...@@ -233,8 +233,11 @@ static void __init ap_init_qci_info(void) ...@@ -233,8 +233,11 @@ static void __init ap_init_qci_info(void)
if (!ap_qci_info) if (!ap_qci_info)
return; return;
ap_qci_info_old = kzalloc(sizeof(*ap_qci_info_old), GFP_KERNEL); ap_qci_info_old = kzalloc(sizeof(*ap_qci_info_old), GFP_KERNEL);
if (!ap_qci_info_old) if (!ap_qci_info_old) {
kfree(ap_qci_info);
ap_qci_info = NULL;
return; return;
}
if (ap_fetch_qci_info(ap_qci_info) != 0) { if (ap_fetch_qci_info(ap_qci_info) != 0) {
kfree(ap_qci_info); kfree(ap_qci_info);
kfree(ap_qci_info_old); kfree(ap_qci_info_old);
......
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