]> git.neil.brown.name Git - history.git/commitdiff
[PATCH] mmap can return incorrect errno
authorChristopher Yeoh <cyeoh@samba.org>
Mon, 11 Feb 2002 14:50:33 +0000 (06:50 -0800)
committerLinus Torvalds <torvalds@home.transmeta.com>
Mon, 11 Feb 2002 14:50:33 +0000 (06:50 -0800)
mmap currently sets errno to EINVAL when it should be ENOMEM.
SUS/POSIX states that ENOMEM should be returned when:

"MAP_FIXED was specified, and the range [addr, addr + len) exceeds
that allowed for the address space of a process; or if MAP_FIXED was
not specified and there is insufficient room in the address space to
effect the mapping."

The following patch (against 2.4.17) fixes this behaviour:

mm/mmap.c

index 8f5662353e7a9f13c3d1d92d97e3e1e480471c37..32ef6f6c95cd124291e7a4cf231981cd2b12f99b 100644 (file)
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -620,7 +620,7 @@ unsigned long get_unmapped_area(struct file *file, unsigned long addr, unsigned
 {
        if (flags & MAP_FIXED) {
                if (addr > TASK_SIZE - len)
-                       return -EINVAL;
+                       return -ENOMEM;
                if (addr & ~PAGE_MASK)
                        return -EINVAL;
                return addr;