aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2010-03-26 18:09:59 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2010-03-26 18:09:59 -0400
commit3cacf42462c8c97e045a07a5fc92aa357489c8b5 (patch)
tree32ed28929899a93c2a3cf9ba5d051d01ed798a7d /kernel
parent6fa41366c1c5e8b9640baba22d2b90ec9035a889 (diff)
parent8bc037fb89bb3104b9ae290d18c877624cd7d9cc (diff)
Merge branch 'sched-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip
* 'sched-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip: sched: Use proper type in sched_getaffinity() kernel/sched.c: Suppress unused var warning sched: sched_getaffinity(): Allow less than NR_CPUS length
Diffstat (limited to 'kernel')
-rw-r--r--kernel/sched.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/kernel/sched.c b/kernel/sched.c
index 9ab3cd7858d3..49d2fa7b687a 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -2650,7 +2650,7 @@ void wake_up_new_task(struct task_struct *p, unsigned long clone_flags)
2650{ 2650{
2651 unsigned long flags; 2651 unsigned long flags;
2652 struct rq *rq; 2652 struct rq *rq;
2653 int cpu = get_cpu(); 2653 int cpu __maybe_unused = get_cpu();
2654 2654
2655#ifdef CONFIG_SMP 2655#ifdef CONFIG_SMP
2656 /* 2656 /*
@@ -4902,7 +4902,9 @@ SYSCALL_DEFINE3(sched_getaffinity, pid_t, pid, unsigned int, len,
4902 int ret; 4902 int ret;
4903 cpumask_var_t mask; 4903 cpumask_var_t mask;
4904 4904
4905 if (len < cpumask_size()) 4905 if (len < nr_cpu_ids)
4906 return -EINVAL;
4907 if (len & (sizeof(unsigned long)-1))
4906 return -EINVAL; 4908 return -EINVAL;
4907 4909
4908 if (!alloc_cpumask_var(&mask, GFP_KERNEL)) 4910 if (!alloc_cpumask_var(&mask, GFP_KERNEL))
@@ -4910,10 +4912,12 @@ SYSCALL_DEFINE3(sched_getaffinity, pid_t, pid, unsigned int, len,
4910 4912
4911 ret = sched_getaffinity(pid, mask); 4913 ret = sched_getaffinity(pid, mask);
4912 if (ret == 0) { 4914 if (ret == 0) {
4913 if (copy_to_user(user_mask_ptr, mask, cpumask_size())) 4915 size_t retlen = min_t(size_t, len, cpumask_size());
4916
4917 if (copy_to_user(user_mask_ptr, mask, retlen))
4914 ret = -EFAULT; 4918 ret = -EFAULT;
4915 else 4919 else
4916 ret = cpumask_size(); 4920 ret = retlen;
4917 } 4921 }
4918 free_cpumask_var(mask); 4922 free_cpumask_var(mask);
4919 4923