aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--mm/madvise.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/mm/madvise.c b/mm/madvise.c
index c8c01a12fea4..4454936f87d1 100644
--- a/mm/madvise.c
+++ b/mm/madvise.c
@@ -37,7 +37,7 @@ static long madvise_behavior(struct vm_area_struct * vma,
37 37
38 if (new_flags == vma->vm_flags) { 38 if (new_flags == vma->vm_flags) {
39 *prev = vma; 39 *prev = vma;
40 goto success; 40 goto out;
41 } 41 }
42 42
43 pgoff = vma->vm_pgoff + ((start - vma->vm_start) >> PAGE_SHIFT); 43 pgoff = vma->vm_pgoff + ((start - vma->vm_start) >> PAGE_SHIFT);
@@ -62,6 +62,7 @@ static long madvise_behavior(struct vm_area_struct * vma,
62 goto out; 62 goto out;
63 } 63 }
64 64
65success:
65 /* 66 /*
66 * vm_flags is protected by the mmap_sem held in write mode. 67 * vm_flags is protected by the mmap_sem held in write mode.
67 */ 68 */
@@ -70,7 +71,6 @@ static long madvise_behavior(struct vm_area_struct * vma,
70out: 71out:
71 if (error == -ENOMEM) 72 if (error == -ENOMEM)
72 error = -EAGAIN; 73 error = -EAGAIN;
73success:
74 return error; 74 return error;
75} 75}
76 76
@@ -237,8 +237,9 @@ asmlinkage long sys_madvise(unsigned long start, size_t len_in, int behavior)
237 * - different from the way of handling in mlock etc. 237 * - different from the way of handling in mlock etc.
238 */ 238 */
239 vma = find_vma_prev(current->mm, start, &prev); 239 vma = find_vma_prev(current->mm, start, &prev);
240 if (!vma && prev) 240 if (vma && start > vma->vm_start)
241 vma = prev->vm_next; 241 prev = vma;
242
242 for (;;) { 243 for (;;) {
243 /* Still start < end. */ 244 /* Still start < end. */
244 error = -ENOMEM; 245 error = -ENOMEM;