diff options
-rw-r--r-- | mm/memory.c | 16 | ||||
-rw-r--r-- | mm/mlock.c | 2 |
2 files changed, 13 insertions, 5 deletions
diff --git a/mm/memory.c b/mm/memory.c index 6793b9c68107..a472bcd4b061 100644 --- a/mm/memory.c +++ b/mm/memory.c | |||
@@ -2765,16 +2765,26 @@ int make_pages_present(unsigned long addr, unsigned long end) | |||
2765 | 2765 | ||
2766 | vma = find_vma(current->mm, addr); | 2766 | vma = find_vma(current->mm, addr); |
2767 | if (!vma) | 2767 | if (!vma) |
2768 | return -1; | 2768 | return -ENOMEM; |
2769 | write = (vma->vm_flags & VM_WRITE) != 0; | 2769 | write = (vma->vm_flags & VM_WRITE) != 0; |
2770 | BUG_ON(addr >= end); | 2770 | BUG_ON(addr >= end); |
2771 | BUG_ON(end > vma->vm_end); | 2771 | BUG_ON(end > vma->vm_end); |
2772 | len = DIV_ROUND_UP(end, PAGE_SIZE) - addr/PAGE_SIZE; | 2772 | len = DIV_ROUND_UP(end, PAGE_SIZE) - addr/PAGE_SIZE; |
2773 | ret = get_user_pages(current, current->mm, addr, | 2773 | ret = get_user_pages(current, current->mm, addr, |
2774 | len, write, 0, NULL, NULL); | 2774 | len, write, 0, NULL, NULL); |
2775 | if (ret < 0) | 2775 | if (ret < 0) { |
2776 | /* | ||
2777 | SUS require strange return value to mlock | ||
2778 | - invalid addr generate to ENOMEM. | ||
2779 | - out of memory should generate EAGAIN. | ||
2780 | */ | ||
2781 | if (ret == -EFAULT) | ||
2782 | ret = -ENOMEM; | ||
2783 | else if (ret == -ENOMEM) | ||
2784 | ret = -EAGAIN; | ||
2776 | return ret; | 2785 | return ret; |
2777 | return ret == len ? 0 : -1; | 2786 | } |
2787 | return ret == len ? 0 : -ENOMEM; | ||
2778 | } | 2788 | } |
2779 | 2789 | ||
2780 | #if !defined(__HAVE_ARCH_GATE_AREA) | 2790 | #if !defined(__HAVE_ARCH_GATE_AREA) |
diff --git a/mm/mlock.c b/mm/mlock.c index 7b2656055d6a..01fbe93eff5c 100644 --- a/mm/mlock.c +++ b/mm/mlock.c | |||
@@ -78,8 +78,6 @@ success: | |||
78 | 78 | ||
79 | mm->locked_vm -= pages; | 79 | mm->locked_vm -= pages; |
80 | out: | 80 | out: |
81 | if (ret == -ENOMEM) | ||
82 | ret = -EAGAIN; | ||
83 | return ret; | 81 | return ret; |
84 | } | 82 | } |
85 | 83 | ||