diff --git a/fs/mmap/fs_rammap.c b/fs/mmap/fs_rammap.c index 23e6ceb330d..d81832e2956 100644 --- a/fs/mmap/fs_rammap.c +++ b/fs/mmap/fs_rammap.c @@ -140,6 +140,12 @@ FAR void *rammap(int fd, size_t length, off_t offset) /* Allocate a region of memory of the specified size */ + if ((unsigned int)fd >= CONFIG_NFILE_DESCRIPTORS) + { + errcode = EBADF; + goto errout; + } + alloc = (FAR uint8_t *)kumm_malloc(sizeof(struct fs_rammap_s) + length); if (!alloc) {