diff --git a/fs/mmap/fs_mmap.c b/fs/mmap/fs_mmap.c index f72633acc90..d4bb97f29d5 100644 --- a/fs/mmap/fs_mmap.c +++ b/fs/mmap/fs_mmap.c @@ -74,6 +74,13 @@ static int file_mmap_(FAR struct file *filep, FAR void *start, */ #ifdef CONFIG_DEBUG_FEATURES + /* A flags with MAP_PRIVATE and MAP_SHARED is invalid. */ + + if ((flags & MAP_PRIVATE) && (flags & MAP_SHARED)) + { + return -EINVAL; + } + /* Fixed mappings and protections are not currently supported. These * options could be supported in the KERNEL build with an MMU, but that * logic is not in place. diff --git a/fs/mmap/fs_munmap.c b/fs/mmap/fs_munmap.c index 85449c1ee5f..41f25a43b34 100644 --- a/fs/mmap/fs_munmap.c +++ b/fs/mmap/fs_munmap.c @@ -69,6 +69,13 @@ static int file_munmap_(FAR void *start, size_t length, bool kernel) mm_map_unlock(); } + /* If entry don't find, the start and length is invalid. */ + + if (entry == NULL) + { + return -EINVAL; + } + return ret; }