fs/mmap/fs_mmap.c: fix errno when fd is not valid

mmap() should return EBADF errno when fd is not valid.
We can just return error code from file_get().

Signed-off-by: p-szafonimateusz <p-szafonimateusz@xiaomi.com>
This commit is contained in:
p-szafonimateusz
2025-09-25 13:24:36 +02:00
committed by Matteo Golin
parent 0c9d0b3f84
commit 20c9ff679c
+2 -3
View File
@@ -287,10 +287,9 @@ FAR void *mmap(FAR void *start, size_t length, int prot, int flags,
FAR void *mapped = NULL;
int ret;
if (fd != -1 && file_get(fd, &filep) < 0)
if (fd != -1 && (ret = file_get(fd, &filep)) < 0)
{
ferr("ERROR: fd:%d referred file whose type is not supported\n", fd);
ret = -ENODEV;
ferr("ERROR: fd:%d referred file is not valid\n", fd);
goto errout;
}