Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1700584

[PATCH] sched: fix NULL pointer issue in pick_next_entity()

From Yafang Shao <laoar.shao@gmail.com>
Newsgroups linux.kernel
Subject [PATCH] sched: fix NULL pointer issue in pick_next_entity()
Date 2017-08-01 04:20 +0200
Message-ID <u9uWS-5OL-7@gated-at.bofh.it> (permalink)
Organization linux.* mail to news gateway

Show all headers | View raw


When we select CFQ as the scheduler, in function pick_next_task_fair
it will pass NULL as the 2nd argument to pick_next_entity:
    pick_next_entity(cfs_rq, NULL);

And once __pick_first_entity() is called, it could return NULL as well.

So in function pick_next_entity(), the local variable 'left' and 'curr'
could both be NULL, then this will cause NULL pointer issue.

In order to fix this issue, we just need return NULL under the condition
that both 'left' and 'curr' are NULL, meaning that no entity available.

Signed-off-by: Yafang Shao <laoar.shao@gmail.com>
---
 kernel/sched/fair.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index c95880e..e64c359 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -3903,6 +3903,8 @@ static void clear_buddies(struct cfs_rq *cfs_rq, struct sched_entity *se)
 	struct sched_entity *left = __pick_first_entity(cfs_rq);
 	struct sched_entity *se;
 
+	if (!left && !curr)
+		return NULL;
 	/*
 	 * If curr is set we have to see if its left of the leftmost entity
 	 * still in the tree, provided there was anything in the tree at all.
-- 
1.8.3.1

Back to linux.kernel | Previous | NextNext in thread | Find similar | Unroll thread


Thread

[PATCH] sched: fix NULL pointer issue in pick_next_entity() Yafang Shao <laoar.shao@gmail.com> - 2017-08-01 04:20 +0200
  Re: [PATCH] sched: fix NULL pointer issue in pick_next_entity() Peter Zijlstra <peterz@infradead.org> - 2017-08-01 10:40 +0200
    Re: [PATCH] sched: fix NULL pointer issue in pick_next_entity() Yafang Shao <laoar.shao@gmail.com> - 2017-08-01 11:00 +0200
    Re: [PATCH] sched: fix NULL pointer issue in pick_next_entity() Peter Zijlstra <peterz@infradead.org> - 2017-08-01 11:20 +0200
      Re: [PATCH] sched: fix NULL pointer issue in pick_next_entity() Yafang Shao <laoar.shao@gmail.com> - 2017-08-01 11:30 +0200
        Re: [PATCH] sched: fix NULL pointer issue in pick_next_entity() Peter Zijlstra <peterz@infradead.org> - 2017-08-01 12:30 +0200

csiph-web