mirror of
https://github.com/apache/nuttx.git
synced 2026-06-07 17:33:08 +08:00
fs/mmap: add fd validation to correct errno
MIRTOS-111 Errors EBADF correctly. This is only a quick fix, and a lot needs to be done with mmap(). Change-Id: Ica88360972447fbdd7c6af3bf76d8eeba4747db2 Signed-off-by: Peter Bee <bijunda1@xiaomi.com>
This commit is contained in:
@@ -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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user