From 20c9ff679c394024d4173287e24144d5cc26bcf3 Mon Sep 17 00:00:00 2001 From: p-szafonimateusz Date: Thu, 25 Sep 2025 13:24:36 +0200 Subject: [PATCH] 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 --- fs/mmap/fs_mmap.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/fs/mmap/fs_mmap.c b/fs/mmap/fs_mmap.c index d58ea4cfdb2..65e757749ea 100644 --- a/fs/mmap/fs_mmap.c +++ b/fs/mmap/fs_mmap.c @@ -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; }