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 <seth.howell@intel.com>
Acked-by: Sergio Gonzalez Monroy <sergio.gonzalez.monroy@intel.com>
This commit is contained in:
Seth Howell 2017-08-28 14:49:12 -07:00 committed by Thomas Monjalon
parent 41baec55a8
commit 7485e06c2a

View 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;
}