[PATCH] msync(bad address) should return -ENOMEM
authorAndrew Morton <akpm@zip.com.au>
Tue, 18 Jun 2002 03:21:34 +0000 (20:21 -0700)
committerLinus Torvalds <torvalds@home.transmeta.com>
Tue, 18 Jun 2002 03:21:34 +0000 (20:21 -0700)
Heaven knows why, but that's what the opengroup say, and returning
-EFAULT causes 2.5 to fail one of the Linux Test Project tests.

[ENOMEM]
          The addresses in the range starting at addr and continuing
          for len bytes are outside the range allowed for the address
          space of a process or specify one or more pages that are not
          mapped.

2.4 has it right, but 2.5 doesn't.

mm/msync.c

index 2a2b31d..5ea980e 100644 (file)
@@ -169,7 +169,7 @@ asmlinkage long sys_msync(unsigned long start, size_t len, int flags)
 {
        unsigned long end;
        struct vm_area_struct * vma;
-       int unmapped_error, error = -EINVAL;
+       int unmapped_error, error = -ENOMEM;
 
        down_read(&current->mm->mmap_sem);
        if (start & ~PAGE_MASK)
@@ -185,18 +185,18 @@ asmlinkage long sys_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 -EFAULT at the end.
+        * just ignore them, but return -ENOMEM at the end.
         */
        vma = find_vma(current->mm, start);
        unmapped_error = 0;
        for (;;) {
                /* Still start < end. */
-               error = -EFAULT;
+               error = -ENOMEM;
                if (!vma)
                        goto out;
                /* Here start < vma->vm_end. */
                if (start < vma->vm_start) {
-                       unmapped_error = -EFAULT;
+                       unmapped_error = -ENOMEM;
                        start = vma->vm_start;
                }
                /* Here vma->vm_start <= start < vma->vm_end. */
@@ -220,5 +220,3 @@ out:
        up_read(&current->mm->mmap_sem);
        return error;
 }
-
-