kernel/sched/core.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index af017e038b48..fdbe7f3b55f0 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -8413,18 +8413,17 @@ SYSCALL_DEFINE3(sched_getaffinity, pid_t, pid, unsigned int, len, return -EINVAL; if (len & (sizeof(unsigned long)-1)) return -EINVAL; + len = BITS_TO_LONGS(nr_cpu_ids) * sizeof(unsigned long); if (!alloc_cpumask_var(&mask, GFP_KERNEL)) return -ENOMEM; ret = sched_getaffinity(pid, mask); if (ret == 0) { - unsigned int retlen = min(len, cpumask_size()); - - if (copy_to_user(user_mask_ptr, mask, retlen)) + if (copy_to_user(user_mask_ptr, mask, len)) ret = -EFAULT; else - ret = retlen; + ret = len; } free_cpumask_var(mask);