fs/inode: check file list before memcpy

The file list is NULL if task group initialized, check the validity
of the file list before memcpy.

Signed-off-by: chao an <anchao@xiaomi.com>
This commit is contained in:
chao an 2023-11-14 23:58:25 +08:00 committed by Alan Carvalho de Assis
parent 0554b975da
commit d63034994e

View File

@ -151,8 +151,11 @@ static int files_extend(FAR struct filelist *list, size_t row)
return OK;
}
if (list->fl_files != NULL)
{
memcpy(files, list->fl_files,
list->fl_rows * sizeof(FAR struct file *));
}
tmp = list->fl_files;
list->fl_files = files;
@ -160,7 +163,10 @@ static int files_extend(FAR struct filelist *list, size_t row)
spin_unlock_irqrestore(&list->fl_lock, flags);
if (tmp != NULL)
{
kmm_free(tmp);
}
return OK;
}