From: Hongbo Yao <yaohongbo(a)huawei.com>
commit 7d23ff6d37d3b32f0fb44880e4dc4c037a86aa37 openEuler-1.0
euler inclusion
category: bugfix
bugzilla: 13254
CVE: NA
---------------------------
Variable "d" going out of scope leaks the storage it points to.
Signed-off-by: Hongbo Yao <yaohongbo(a)huawei.com>
Reviewed-by: Xie XiuQi <xiexiuqi(a)huawei.com>
Signed-off-by: Yang Yingliang <yangyingliang(a)huawei.com>
Signed-off-by: Xin Hao <haoxing990(a)gmail.com>
---
arch/arm64/kernel/mpam.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/arch/arm64/kernel/mpam.c b/arch/arm64/kernel/mpam.c
index d18868d0b296..eb9e38284bc7 100644
--- a/arch/arm64/kernel/mpam.c
+++ b/arch/arm64/kernel/mpam.c
@@ -1219,8 +1219,10 @@ static void mpam_domains_init(struct resctrl_resource *r)
d->cpus_list = n->cpus_list;
d->ctrl_val = kmalloc_array(rr->num_partid, sizeof(*d->ctrl_val),
GFP_KERNEL);
- if (!d->ctrl_val)
+ if (!d->ctrl_val) {
+ kfree(d);
return;
+ }
list_add_tail(&d->list, add_pos);
--
2.31.0