diff --git a/fs/inode/fs_files.c b/fs/inode/fs_files.c index ba310176f4..7d4eaf77d5 100644 --- a/fs/inode/fs_files.c +++ b/fs/inode/fs_files.c @@ -71,6 +71,11 @@ static int files_extend(FAR struct filelist *list, size_t row) return 0; } + if (row * CONFIG_NFILE_DESCRIPTORS_PER_BLOCK > _POSIX_OPEN_MAX) + { + return -EMFILE; + } + tmp = kmm_realloc(list->fl_files, sizeof(FAR struct file *) * row); DEBUGASSERT(tmp); if (tmp == NULL)