From 7485e06c2afb6baba38ce03228638aed8d903c62 Mon Sep 17 00:00:00 2001 From: Seth Howell Date: Mon, 28 Aug 2017 14:49:12 -0700 Subject: [PATCH] mem: check mmap failure 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 Acked-by: Sergio Gonzalez Monroy --- 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 e2ea120d2e..28bca49520 100644 --- a/lib/librte_eal/linuxapp/eal/eal_memory.c +++ b/lib/librte_eal/linuxapp/eal/eal_memory.c @@ -685,6 +685,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.20.1