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:
Peter Bee
2021-01-21 11:36:52 +08:00
committed by bijunda1
parent a77d103263
commit 1cd87d6f97
+6
View File
@@ -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)
{