From 0c44eb86b40dbaddae8428f7692e45321d982802 Mon Sep 17 00:00:00 2001 From: Maria Yu Date: Wed, 24 Nov 2021 15:31:25 +0800 Subject: [PATCH] sched/walt: Deal with mvp_list at the very initial stage When the android vendor hook is not registered yet, there is already tasks. And if those kind of tasks being killed without any wakeup after vendor hook registered, it will be a NULL referenced data. Change-Id: Ied2eb3805dd01740a01707e2016c24a4648b1b25 Signed-off-by: Maria Yu --- kernel/sched/walt/walt_cfs.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/kernel/sched/walt/walt_cfs.c b/kernel/sched/walt/walt_cfs.c index 5d6c3f53dd08..82f54d187d0a 100644 --- a/kernel/sched/walt/walt_cfs.c +++ b/kernel/sched/walt/walt_cfs.c @@ -1148,7 +1148,7 @@ void walt_cfs_dequeue_task(struct rq *rq, struct task_struct *p) { struct walt_task_struct *wts = (struct walt_task_struct *) p->android_vendor_data1; - if (!list_empty(&wts->mvp_list)) + if (!list_empty(&wts->mvp_list) && wts->mvp_list.next) walt_cfs_deactivate_mvp_task(p); /* @@ -1171,7 +1171,7 @@ void walt_cfs_tick(struct rq *rq) raw_spin_lock(&rq->__lock); - if (list_empty(&wts->mvp_list)) + if (list_empty(&wts->mvp_list) || (wts->mvp_list.next == NULL)) goto out; walt_cfs_account_mvp_runtime(rq, rq->curr); @@ -1205,8 +1205,8 @@ static void walt_cfs_check_preempt_wakeup(void *unused, struct rq *rq, struct ta if (unlikely(walt_disabled)) return; - p_is_mvp = !list_empty(&wts_p->mvp_list); - curr_is_mvp = !list_empty(&wts_c->mvp_list); + p_is_mvp = !list_empty(&wts_p->mvp_list) && wts_p->mvp_list.next; + curr_is_mvp = !list_empty(&wts_c->mvp_list) && wts_c->mvp_list.next; /* * current is not MVP, so preemption decision