From: Simon Glass <sjg@chromium.org> os_map_file() returns -EPERM for all mmap() failures regardless of the actual errno. When mmap() fails with ENOMEM, return -ENOMEM so that callers can distinguish out-of-memory from other errors. Signed-off-by: Simon Glass <sjg@chromium.org> --- arch/sandbox/cpu/os.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/sandbox/cpu/os.c b/arch/sandbox/cpu/os.c index 142b685e031..c1381775b1b 100644 --- a/arch/sandbox/cpu/os.c +++ b/arch/sandbox/cpu/os.c @@ -299,7 +299,7 @@ int os_map_file(const char *pathname, int os_flags, void **bufp, int *sizep) ptr = mmap(0, size, PROT_READ | PROT_WRITE, MAP_SHARED, ifd, 0); if (ptr == MAP_FAILED) { printf("Can't map file '%s': %s\n", pathname, strerror(errno)); - ret = -EPERM; + ret = errno == ENOMEM ? -ENOMEM : -EPERM; goto out; } -- 2.43.0