s390/ap: fix memory leak in ap_init_qci_info()

[ Upstream commit 9ac74f0666 ]

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: 283915850a ("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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
Wei Yongjun 2022-11-14 11:08:29 +00:00 committed by Greg Kroah-Hartman
parent 6746da1e73
commit 84e6a57da1
1 changed files with 4 additions and 1 deletions

View File

@ -233,8 +233,11 @@ static void __init ap_init_qci_info(void)
if (!ap_qci_info)
return;
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;
}
if (ap_fetch_qci_info(ap_qci_info) != 0) {
kfree(ap_qci_info);
kfree(ap_qci_info_old);