Commit af0d81ab authored by Zheng Zucheng's avatar Zheng Zucheng Committed by Yang Yingliang
Browse files

sched: Avoid sched entity null pointer panic

hulk inclusion
category: bugfix
bugzilla: 51828, https://gitee.com/openeuler/kernel/issues/I4K96G


CVE: NA

--------------------------------

In some corner case, when we throttle the last group sched entity in rq,
kernel will be panic if there is no residual sched entities in rq. So we
add a protection to prevent this case.

Signed-off-by: default avatarZheng Zucheng <zhengzucheng@huawei.com>
Reviewed-by: default avatarChen Hui <judy.chenhui@huawei.com>
Reviewed-by: default avatarXiu Jianfeng <xiujianfeng@huawei.com>
Signed-off-by: default avatarYang Yingliang <yangyingliang@huawei.com>
parent 698ed717
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -7050,7 +7050,11 @@ pick_next_task_fair(struct rq *rq, struct task_struct *prev, struct rq_flags *rf
			     cfs_rq->h_nr_running == cfs_rq->idle_h_nr_running)) {
			throttle_qos_cfs_rq(cfs_rq);
			cfs_rq = &rq->cfs;
			WARN_ON(cfs_rq->nr_running == 0);
			WARN(cfs_rq->nr_running == 0,
			     "rq->nr_running=%u, cfs_rq->idle_h_nr_running=%u\n",
			     rq->nr_running, cfs_rq->idle_h_nr_running);
			if (unlikely(!cfs_rq->nr_running))
				return NULL;
		}
#endif
	} while (cfs_rq);