aboutsummaryrefslogtreecommitdiffstats
path: root/fs/proc/task_mmu.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/proc/task_mmu.c')
-rw-r--r--fs/proc/task_mmu.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
index 59e98fea34a4..366b1017a4f1 100644
--- a/fs/proc/task_mmu.c
+++ b/fs/proc/task_mmu.c
@@ -473,21 +473,20 @@ static ssize_t clear_refs_write(struct file *file, const char __user *buf,
473 size_t count, loff_t *ppos) 473 size_t count, loff_t *ppos)
474{ 474{
475 struct task_struct *task; 475 struct task_struct *task;
476 char buffer[PROC_NUMBUF], *end; 476 char buffer[PROC_NUMBUF];
477 struct mm_struct *mm; 477 struct mm_struct *mm;
478 struct vm_area_struct *vma; 478 struct vm_area_struct *vma;
479 int type; 479 long type;
480 480
481 memset(buffer, 0, sizeof(buffer)); 481 memset(buffer, 0, sizeof(buffer));
482 if (count > sizeof(buffer) - 1) 482 if (count > sizeof(buffer) - 1)
483 count = sizeof(buffer) - 1; 483 count = sizeof(buffer) - 1;
484 if (copy_from_user(buffer, buf, count)) 484 if (copy_from_user(buffer, buf, count))
485 return -EFAULT; 485 return -EFAULT;
486 type = simple_strtol(buffer, &end, 0); 486 if (strict_strtol(strstrip(buffer), 10, &type))
487 return -EINVAL;
487 if (type < CLEAR_REFS_ALL || type > CLEAR_REFS_MAPPED) 488 if (type < CLEAR_REFS_ALL || type > CLEAR_REFS_MAPPED)
488 return -EINVAL; 489 return -EINVAL;
489 if (*end == '\n')
490 end++;
491 task = get_proc_task(file->f_path.dentry->d_inode); 490 task = get_proc_task(file->f_path.dentry->d_inode);
492 if (!task) 491 if (!task)
493 return -ESRCH; 492 return -ESRCH;
@@ -523,9 +522,8 @@ static ssize_t clear_refs_write(struct file *file, const char __user *buf,
523 mmput(mm); 522 mmput(mm);
524 } 523 }
525 put_task_struct(task); 524 put_task_struct(task);
526 if (end - buffer == 0) 525
527 return -EIO; 526 return count;
528 return end - buffer;
529} 527}
530 528
531const struct file_operations proc_clear_refs_operations = { 529const struct file_operations proc_clear_refs_operations = {