[PATCH 2.6] fix mmap() return value to conform POSIX

From: Gordon Jin
Date: Mon Mar 14 2005 - 22:12:47 EST


This patch fixes 2 return values in mmap() to conform POSIX spec:

[EINVAL]
The value of len is zero.

[ENOMEM]
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.

--- linux-2.6.11.3/mm/mmap.c.orig 2005-03-14 13:20:11.000000000 -0800
+++ linux-2.6.11.3/mm/mmap.c 2005-03-14 17:24:37.000000000 -0800
@@ -897,12 +897,12 @@ unsigned long do_mmap_pgoff(struct file
prot |= PROT_EXEC;

if (!len)
- return addr;
+ return -EINVAL;

/* Careful about overflows.. */
len = PAGE_ALIGN(len);
if (!len || len > TASK_SIZE)
- return -EINVAL;
+ return -ENOMEM;

/* offset overflow? */
if ((pgoff + (len >> PAGE_SHIFT)) < pgoff)


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/