From: Gordon Jin 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. Signed-off-by: Andrew Morton --- 25-akpm/mm/mmap.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff -puN mm/mmap.c~fix-mmap-return-value-to-conform-posix mm/mmap.c --- 25/mm/mmap.c~fix-mmap-return-value-to-conform-posix 2005-03-14 19:12:49.000000000 -0800 +++ 25-akpm/mm/mmap.c 2005-03-14 19:12:49.000000000 -0800 @@ -896,12 +896,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) _