mem: check mmap failure
authorSeth Howell <seth.howell@intel.com>
Mon, 28 Aug 2017 21:49:12 +0000 (14:49 -0700)
committerThomas Monjalon <thomas@monjalon.net>
Mon, 9 Oct 2017 21:17:04 +0000 (23:17 +0200)
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 <seth.howell@intel.com>
Acked-by: Sergio Gonzalez Monroy <sergio.gonzalez.monroy@intel.com>
lib/librte_eal/linuxapp/eal/eal_memory.c

index e2ea120..28bca49 100644 (file)
@@ -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;
 }