Thread (5 messages) read the whole thread 5 messages, 3 authors, 2017-10-09
STALE3216d

[PATCH] eal/linuxapp: check mmap return value MAP_FAILED

From: Seth Howell <hidden>
Date: 2017-08-15 20:53:41
Subsystem: library code, the rest · Maintainers: Andrew Morton, Linus Torvalds

If mmap fails, it will return the value MAP_FAILED. Checking for this return
code allows us to properly identify mmap failures and report them as such
to the calling function.

Signed-off-by: Seth Howell <redacted>
---
 lib/librte_eal/linuxapp/eal/eal_memory.c | 2 ++
 1 file changed, 2 insertions(+)
diff --git a/lib/librte_eal/linuxapp/eal/eal_memory.c b/lib/librte_eal/linuxapp/eal/eal_memory.c
index 5279128..ba76b02 100644
--- a/lib/librte_eal/linuxapp/eal/eal_memory.c
+++ b/lib/librte_eal/linuxapp/eal/eal_memory.c
@@ -716,6 +716,8 @@ create_shared_memory(const char *filename, const size_t mem_size)
 	}
 	retval = mmap(NULL, mem_size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
 	close(fd);
+	if (retval == MAP_FAILED)
+	    return NULL;
 	return retval;
 }
 
-- 
2.9.5
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help