fs/mmap: add sanity check
Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
This commit is contained in:
parent
e4739ab575
commit
88161bfca5
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue