mm/msync: exit early when the flags is an MS_ASYNC and start < vm_start
[linux-2.6-microblaze.git] / mm / msync.c
index 69c6d20..137d1c1 100644 (file)
@@ -55,7 +55,9 @@ SYSCALL_DEFINE3(msync, unsigned long, start, size_t, len, int, flags)
                goto out;
        /*
         * If the interval [start,end) covers some unmapped address ranges,
-        * just ignore them, but return -ENOMEM at the end.
+        * just ignore them, but return -ENOMEM at the end. Besides, if the
+        * flag is MS_ASYNC (w/o MS_INVALIDATE) the result would be -ENOMEM
+        * anyway and there is nothing left to do, so return immediately.
         */
        mmap_read_lock(mm);
        vma = find_vma(mm, start);
@@ -69,6 +71,8 @@ SYSCALL_DEFINE3(msync, unsigned long, start, size_t, len, int, flags)
                        goto out_unlock;
                /* Here start < vma->vm_end. */
                if (start < vma->vm_start) {
+                       if (flags == MS_ASYNC)
+                               goto out_unlock;
                        start = vma->vm_start;
                        if (start >= end)
                                goto out_unlock;