diff --git a/patches.suse/powerpc-pseries-Fix-potential-memleak-in-papr_get_at.patch b/patches.suse/powerpc-pseries-Fix-potential-memleak-in-papr_get_at.patch new file mode 100644 index 0000000..426fcb5 --- /dev/null +++ b/patches.suse/powerpc-pseries-Fix-potential-memleak-in-papr_get_at.patch @@ -0,0 +1,44 @@ +From cda9c0d556283e2d4adaa9960b2dc19b16156bae Mon Sep 17 00:00:00 2001 +From: Qiheng Lin +Date: Thu, 8 Dec 2022 21:34:49 +0800 +Subject: [PATCH] powerpc/pseries: Fix potential memleak in papr_get_attr() + +References: bsc#1200465 ltc#197256 jsc#SLE-18130 git-fixes +Patch-mainline: v6.9-rc1 +Git-commit: cda9c0d556283e2d4adaa9960b2dc19b16156bae + +`buf` is allocated in papr_get_attr(), and krealloc() of `buf` +could fail. We need to free the original `buf` in the case of failure. + +Fixes: 3c14b73454cf ("powerpc/pseries: Interface to represent PAPR firmware attributes") +Signed-off-by: Qiheng Lin +Signed-off-by: Michael Ellerman +Link: https://msgid.link/20221208133449.16284-1-linqiheng@huawei.com +Acked-by: Michal Suchanek +--- + arch/powerpc/platforms/pseries/papr_platform_attributes.c | 8 +++++--- + 1 file changed, 5 insertions(+), 3 deletions(-) + +diff --git a/arch/powerpc/platforms/pseries/papr_platform_attributes.c b/arch/powerpc/platforms/pseries/papr_platform_attributes.c +index 526c621b098b..eea2041b270b 100644 +--- a/arch/powerpc/platforms/pseries/papr_platform_attributes.c ++++ b/arch/powerpc/platforms/pseries/papr_platform_attributes.c +@@ -101,10 +101,12 @@ static int papr_get_attr(u64 id, struct energy_scale_attribute *esi) + esi_buf_size = ESI_HDR_SIZE + (CURR_MAX_ESI_ATTRS * max_esi_attrs); + + temp_buf = krealloc(buf, esi_buf_size, GFP_KERNEL); +- if (temp_buf) ++ if (temp_buf) { + buf = temp_buf; +- else +- return -ENOMEM; ++ } else { ++ ret = -ENOMEM; ++ goto out_buf; ++ } + + goto retry; + } +-- +2.44.0 + diff --git a/series.conf b/series.conf index 4a0a280..66948e2 100644 --- a/series.conf +++ b/series.conf @@ -45683,6 +45683,7 @@ patches.suse/ALSA-usb-audio-Stop-parsing-channels-bits-when-all-c.patch patches.suse/nilfs2-fix-failure-to-detect-DAT-corruption-in-btree.patch patches.suse/nilfs2-prevent-kernel-bug-at-submit_bh_wbc.patch + patches.suse/powerpc-pseries-Fix-potential-memleak-in-papr_get_at.patch # jejb/scsi for-next patches.suse/scsi-lpfc-Initialize-status-local-variable-in-lpfc_s.patch