mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] sched: Fix sched_policy < 0 comparison
@ 2014-06-02 20:38 Richard Weinberger
  2014-06-03  8:26 ` Peter Zijlstra
  2014-06-05 14:33 ` [tip:sched/urgent] " tip-bot for Richard Weinberger
  0 siblings, 2 replies; 3+ messages in thread
From: Richard Weinberger @ 2014-06-02 20:38 UTC (permalink / raw)
  To: peterz; +Cc: linux-kernel, Richard Weinberger, Michael Kerrisk, Ingo Molnar

attr.sched_policy is u32, therefore a comparison against < 0 is never true.
Fix this by casting sched_policy to int.

This issue was reported by coverity CID 1219934.

Cc: Michael Kerrisk <mtk.manpages@gmail.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Richard Weinberger <richard@nod.at>
---
 kernel/sched/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index b8cd08f..d579476 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -3726,7 +3726,7 @@ SYSCALL_DEFINE3(sched_setattr, pid_t, pid, struct sched_attr __user *, uattr,
 	if (retval)
 		return retval;
 
-	if (attr.sched_policy < 0)
+	if ((int)attr.sched_policy < 0)
 		return -EINVAL;
 
 	rcu_read_lock();
-- 
1.8.1.4


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-06-05 14:34 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-06-02 20:38 [PATCH] sched: Fix sched_policy < 0 comparison Richard Weinberger
2014-06-03  8:26 ` Peter Zijlstra
2014-06-05 14:33 ` [tip:sched/urgent] " tip-bot for Richard Weinberger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome