Skip to contentSkip to conversation

cfs: NULL pointer check

PATCH NAK Wang Xingchao 3 participants 4 messages Sep 16, 2011

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cfs: NULL pointer check

se maybe NULL if cfs_rq->rb_leftmost is NULL

---
 kernel/sched_fair.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
kernel/sched_fair.c +4 -0
index fef0bfd..109b232 100644
@@ -1130,6 +1130,10 @@ check_preempt_tick(struct cfs_rq *cfs_rq, struct sched_entity *curr)
 		return;
 
 	se = __pick_first_entity(cfs_rq);
+
+	if (!se)
+		return;
+
 	delta = curr->vruntime - se->vruntime;
 
 	if (delta < 0)
Signature · 1 line
1.7.1
#1 lore raw
Quoted 1 line · Wang Xingchao

se maybe NULL if cfs_rq->rb_leftmost is NULL

I don't think se could be NULL here. Because we call check_preempt_tick() iff 'cfs_rq->nr_running > 1'.

Thanks,
Yong

Quoted 29 lines
---
 kernel/sched_fair.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
kernel/sched_fair.c +4 -0
index fef0bfd..109b232 100644
@@ -1130,6 +1130,10 @@ check_preempt_tick(struct cfs_rq *cfs_rq, struct sched_entity *curr)
 		return;
 
 	se = __pick_first_entity(cfs_rq);
+
+	if (!se)
+		return;
+
 	delta = curr->vruntime - se->vruntime;
 
 	if (delta < 0)
Signature · 7 lines
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/
Signature · 1 line
Only stand for myself
#2 lore raw
In reply to Wang Xingchao
Quoted 1 line · Wang Xingchao

se maybe NULL if cfs_rq->rb_leftmost is NULL

nack, it had better not be; otherwise we've got a corrupt tree!

Also, this diff is against the previous -- please bundle dependent patches as a series in the future.

Thanks,

- Paul

Quoted 21 lines
---
  kernel/sched_fair.c |    4 ++++
  1 files changed, 4 insertions(+), 0 deletions(-)
kernel/sched_fair.c +4 -0
index fef0bfd..109b232 100644
@@ -1130,6 +1130,10 @@ check_preempt_tick(struct cfs_rq *cfs_rq, struct sched_entity *curr)
  		return;
 
  	se = __pick_first_entity(cfs_rq);
+
+	if (!se)
+		return;
+
  	delta = curr->vruntime - se->vruntime;
 
  	if (delta<  0)
author
#3 lore raw
Quoted 8 lines · On Fri, 16 Sep 2011 15:42:41 +0800 Paul Turner <[email protected]> wrote:
Quoted 1 line · Wang Xingchao

se maybe NULL if cfs_rq->rb_leftmost is NULL

nack, it had better not be; otherwise we've got a corrupt tree!

Also, this diff is against the previous -- please bundle dependent patches as a series in the future.

Got it. :)
Paul, i'd send another patch to remove the NULL pointer check in __pick_first/last_entity().

--xingchao