aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/sched.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/sched.c')
-rw-r--r--kernel/sched.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/kernel/sched.c b/kernel/sched.c
index 67383e7f1ccd..6deff24349b6 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -5499,19 +5499,24 @@ asmlinkage long sys_sched_getaffinity(pid_t pid, unsigned int len,
5499 unsigned long __user *user_mask_ptr) 5499 unsigned long __user *user_mask_ptr)
5500{ 5500{
5501 int ret; 5501 int ret;
5502 cpumask_t mask; 5502 cpumask_var_t mask;
5503 5503
5504 if (len < sizeof(cpumask_t)) 5504 if (len < cpumask_size())
5505 return -EINVAL; 5505 return -EINVAL;
5506 5506
5507 ret = sched_getaffinity(pid, &mask); 5507 if (!alloc_cpumask_var(&mask, GFP_KERNEL))
5508 if (ret < 0) 5508 return -ENOMEM;
5509 return ret;
5510 5509
5511 if (copy_to_user(user_mask_ptr, &mask, sizeof(cpumask_t))) 5510 ret = sched_getaffinity(pid, mask);
5512 return -EFAULT; 5511 if (ret == 0) {
5512 if (copy_to_user(user_mask_ptr, mask, cpumask_size()))
5513 ret = -EFAULT;
5514 else
5515 ret = cpumask_size();
5516 }
5517 free_cpumask_var(mask);
5513 5518
5514 return sizeof(cpumask_t); 5519 return ret;
5515} 5520}
5516 5521
5517/** 5522/**