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 Signed-off-by: Yipeng Zou zouyipeng@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 040bb91da98d..b93bde0af473 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -6156,7 +6156,6 @@ static int init_affinity_domains(struct affinity_domain *ad) }
if (!sd) { - ad->dcount = 0; rcu_read_unlock(); return -EINVAL; } @@ -6164,8 +6163,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();