mirror of
https://github.com/apache/nuttx.git
synced 2026-05-25 01:39:44 +08:00
fs/mmap: add sanity check
Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user