sched/deadline: No need to check p if dl_se is valid
authorJuri Lelli <juri.lelli@gmail.com>
Tue, 14 Jan 2014 11:03:51 +0000 (12:03 +0100)
committerIngo Molnar <mingo@kernel.org>
Thu, 16 Jan 2014 08:27:11 +0000 (09:27 +0100)
Dan Carpenter reported new 'Smatch' warnings:

  > tree:   git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git sched/core
  > head:   130816ce4d5f69167324f7272e70aa3d641677c6
  > commit: 1baca4ce16b8cc7d4f50be1f7914799af30a2861 [17/50] sched/deadline: Add SCHED_DEADLINE SMP-related data structures & logic
  >
  > kernel/sched/deadline.c:937 pick_next_task_dl() warn: variable dereferenced before check 'p' (see line 934)

BUG_ON() already fires if pick_next_dl_entity() doesn't return a valid
dl_se. No need to check if p is valid afterward.

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Juri Lelli <juri.lelli@gmail.com>
Signed-off-by: Peter Zijlstra <peterz@infradead.org>
Fixes: 1baca4ce16b8 ("sched/deadline: Add SCHED_DEADLINE SMP-related data structures & logic")
Link: http://lkml.kernel.org/r/52D54E25.6060100@gmail.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
kernel/sched/deadline.c

index ee25361becdd09e8b836b8a973262c2690e33f1f..0de248202879311be46a10b0ab855cba0c512ce6 100644 (file)
@@ -1007,8 +1007,7 @@ struct task_struct *pick_next_task_dl(struct rq *rq)
        p->se.exec_start = rq_clock_task(rq);
 
        /* Running task will never be pushed. */
-       if (p)
-               dequeue_pushable_dl_task(rq, p);
+       dequeue_pushable_dl_task(rq, p);
 
 #ifdef CONFIG_SCHED_HRTICK
        if (hrtick_enabled(rq))