diff options
-rw-r--r-- | fs/proc/task_mmu.c | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c index 3e636d864d56..dad0809db551 100644 --- a/fs/proc/task_mmu.c +++ b/fs/proc/task_mmu.c | |||
@@ -688,6 +688,13 @@ const struct file_operations proc_tid_smaps_operations = { | |||
688 | .release = seq_release_private, | 688 | .release = seq_release_private, |
689 | }; | 689 | }; |
690 | 690 | ||
691 | enum clear_refs_types { | ||
692 | CLEAR_REFS_ALL = 1, | ||
693 | CLEAR_REFS_ANON, | ||
694 | CLEAR_REFS_MAPPED, | ||
695 | CLEAR_REFS_LAST, | ||
696 | }; | ||
697 | |||
691 | static int clear_refs_pte_range(pmd_t *pmd, unsigned long addr, | 698 | static int clear_refs_pte_range(pmd_t *pmd, unsigned long addr, |
692 | unsigned long end, struct mm_walk *walk) | 699 | unsigned long end, struct mm_walk *walk) |
693 | { | 700 | { |
@@ -719,10 +726,6 @@ static int clear_refs_pte_range(pmd_t *pmd, unsigned long addr, | |||
719 | return 0; | 726 | return 0; |
720 | } | 727 | } |
721 | 728 | ||
722 | #define CLEAR_REFS_ALL 1 | ||
723 | #define CLEAR_REFS_ANON 2 | ||
724 | #define CLEAR_REFS_MAPPED 3 | ||
725 | |||
726 | static ssize_t clear_refs_write(struct file *file, const char __user *buf, | 729 | static ssize_t clear_refs_write(struct file *file, const char __user *buf, |
727 | size_t count, loff_t *ppos) | 730 | size_t count, loff_t *ppos) |
728 | { | 731 | { |
@@ -730,7 +733,8 @@ static ssize_t clear_refs_write(struct file *file, const char __user *buf, | |||
730 | char buffer[PROC_NUMBUF]; | 733 | char buffer[PROC_NUMBUF]; |
731 | struct mm_struct *mm; | 734 | struct mm_struct *mm; |
732 | struct vm_area_struct *vma; | 735 | struct vm_area_struct *vma; |
733 | int type; | 736 | enum clear_refs_types type; |
737 | int itype; | ||
734 | int rv; | 738 | int rv; |
735 | 739 | ||
736 | memset(buffer, 0, sizeof(buffer)); | 740 | memset(buffer, 0, sizeof(buffer)); |
@@ -738,10 +742,11 @@ static ssize_t clear_refs_write(struct file *file, const char __user *buf, | |||
738 | count = sizeof(buffer) - 1; | 742 | count = sizeof(buffer) - 1; |
739 | if (copy_from_user(buffer, buf, count)) | 743 | if (copy_from_user(buffer, buf, count)) |
740 | return -EFAULT; | 744 | return -EFAULT; |
741 | rv = kstrtoint(strstrip(buffer), 10, &type); | 745 | rv = kstrtoint(strstrip(buffer), 10, &itype); |
742 | if (rv < 0) | 746 | if (rv < 0) |
743 | return rv; | 747 | return rv; |
744 | if (type < CLEAR_REFS_ALL || type > CLEAR_REFS_MAPPED) | 748 | type = (enum clear_refs_types)itype; |
749 | if (type < CLEAR_REFS_ALL || type >= CLEAR_REFS_LAST) | ||
745 | return -EINVAL; | 750 | return -EINVAL; |
746 | task = get_proc_task(file_inode(file)); | 751 | task = get_proc_task(file_inode(file)); |
747 | if (!task) | 752 | if (!task) |