[PATCH] sched: Fix rt/dl hotplug condition

From: Peter Zijlstra
Date: Wed Feb 12 2014 - 04:49:52 EST


Dan Carpenter reported:

> kernel/sched/rt.c:1347 pick_next_task_rt() warn: variable dereferenced before check 'prev' (see line 1338)
> kernel/sched/deadline.c:1011 pick_next_task_dl() warn: variable dereferenced before check 'prev' (see line 1005)

Cc: Steven Rostedt <rostedt@xxxxxxxxxxx>
Cc: Juri Lelli <juri.lelli@xxxxxxxxx>
Fixes: 38033c37faab ("sched: Push down pre_schedule() and idle_balance()")
Reported-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx>
Signed-off-by: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
---
kernel/sched/deadline.c | 2 +-
kernel/sched/rt.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c
index ed31ef66ab9d..d60008e4bce9 100644
--- a/kernel/sched/deadline.c
+++ b/kernel/sched/deadline.c
@@ -1001,7 +1001,7 @@ struct task_struct *pick_next_task_dl(struct rq *rq, struct task_struct *prev)
dl_rq = &rq->dl;

#ifdef CONFIG_SMP
- if (dl_task(prev))
+ if (prev && dl_task(prev))
pull_dl_task(rq);
#endif

diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c
index 72f9ec759972..7294b498b2c1 100644
--- a/kernel/sched/rt.c
+++ b/kernel/sched/rt.c
@@ -1334,7 +1334,7 @@ pick_next_task_rt(struct rq *rq, struct task_struct *prev)

#ifdef CONFIG_SMP
/* Try to pull RT tasks here if we lower this rq's prio */
- if (rq->rt.highest_prio.curr > prev->prio)
+ if (prev && (rq->rt.highest_prio.curr > prev->prio))
pull_rt_task(rq);
#endif

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/