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
This commit is contained in:
Linus Torvalds 2010-03-26 15:09:59 -07:00
commit 3cacf42462

View File

@ -2650,7 +2650,7 @@ void wake_up_new_task(struct task_struct *p, unsigned long clone_flags)
{ {
unsigned long flags; unsigned long flags;
struct rq *rq; struct rq *rq;
int cpu = get_cpu(); int cpu __maybe_unused = get_cpu();
#ifdef CONFIG_SMP #ifdef CONFIG_SMP
/* /*
@ -4902,7 +4902,9 @@ SYSCALL_DEFINE3(sched_getaffinity, pid_t, pid, unsigned int, len,
int ret; int ret;
cpumask_var_t mask; cpumask_var_t mask;
if (len < cpumask_size()) if (len < nr_cpu_ids)
return -EINVAL;
if (len & (sizeof(unsigned long)-1))
return -EINVAL; return -EINVAL;
if (!alloc_cpumask_var(&mask, GFP_KERNEL)) if (!alloc_cpumask_var(&mask, GFP_KERNEL))
@ -4910,10 +4912,12 @@ SYSCALL_DEFINE3(sched_getaffinity, pid_t, pid, unsigned int, len,
ret = sched_getaffinity(pid, mask); ret = sched_getaffinity(pid, mask);
if (ret == 0) { if (ret == 0) {
if (copy_to_user(user_mask_ptr, mask, cpumask_size())) size_t retlen = min_t(size_t, len, cpumask_size());
if (copy_to_user(user_mask_ptr, mask, retlen))
ret = -EFAULT; ret = -EFAULT;
else else
ret = cpumask_size(); ret = retlen;
} }
free_cpumask_var(mask); free_cpumask_var(mask);