From: Hui Tang tanghui20@huawei.com
hulk inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I7EBNA CVE: NA
-------------------------------
Fix memory leak on error branch for smart grid.
Fixes: 713cfd2684fa ("sched: Introduce smart grid scheduling strategy for cfs") Signed-off-by: Hui Tang tanghui20@huawei.com Reviewed-by: Zhang Qiao zhangqiao22@huawei.com Signed-off-by: Zhang Changzhong zhangchangzhong@huawei.com --- kernel/sched/fair.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 3c2bdbf..2115d79 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -5628,7 +5628,6 @@ static int init_affinity_domains(struct affinity_domain *ad) }
if (!sd) { - ad->dcount = 0; rcu_read_unlock(); return -EINVAL; } @@ -5636,8 +5635,10 @@ static int init_affinity_domains(struct affinity_domain *ad)
for (i = 0; i < dcount; i++) { ad->domains[i] = kmalloc(sizeof(cpumask_t), GFP_KERNEL); - if (!ad->domains[i]) + if (!ad->domains[i]) { + ad->dcount = i; goto err; + } }
rcu_read_lock();