Skip to contentSkip to conversation

mips/mm/mmap: fix the wrong return value from syscall mmap() on mips architecture

PATCH New Yang Yi 1 participant 1 message Jul 25, 2018 MIPS

lore
Share & tools
lore

Yang Yi

author
#0 lore raw

PATCH 1/1 mips/mm/mmap: fix the wrong return value from syscall mmap() on mips architecture

According to the latest POSIX standard defined in IEEE Std 1003.1-2017, the errno should be set to ENOMEM instead of EINVAL when mmap into high region address which exceeds the address boundary of a process.

The corresponding description of IEEE Std 1003.1-2017 is as follows:

ERRORS
The mmap() function shall fail if:
......
[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.
......

---
 arch/mips/mm/mmap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/mips/mm/mmap.c +1 -1
index 2f616eb..c47059c 100755
@@ -69,7 +69,7 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp,
 	if (flags & MAP_FIXED) {
 		/* Even MAP_FIXED mappings must reside within TASK_SIZE */
 		if (TASK_SIZE - len < addr)
-			return -EINVAL;
+			return -ENOMEM;
 
 		/*
 		 * We do not accept a shared mapping if it would violate

--
2.1.0.GIT