Commit 1e54dd8a authored by Christopher Yeoh's avatar Christopher Yeoh Committed by Linus Torvalds

[PATCH] mmap can return incorrect errno

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:
parent ba443ea9
......@@ -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;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment