Skip to content

Commit

Permalink
fs/inode: using orig_row to ensure correct free logic
Browse files Browse the repository at this point in the history
Signed-off-by: dongjiuzhu1 <[email protected]>
  • Loading branch information
Donny9 authored and xiaoxiang781216 committed Sep 8, 2024
1 parent 6542806 commit 2a8c023
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions fs/inode/fs_files.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,33 +90,32 @@ static int files_extend(FAR struct filelist *list, size_t row)
int i;
int j;

if (row <= list->fl_rows)
orig_rows = list->fl_rows;
if (row <= orig_rows)
{
return 0;
}

if (files_countlist(list) > OPEN_MAX)
if (CONFIG_NFILE_DESCRIPTORS_PER_BLOCK * orig_rows > OPEN_MAX)
{
return -EMFILE;
}

orig_rows = list->fl_rows;

files = kmm_malloc(sizeof(FAR struct file *) * row);
DEBUGASSERT(files);
if (files == NULL)
{
return -ENFILE;
}

i = list->fl_rows;
i = orig_rows;
do
{
files[i] = kmm_zalloc(sizeof(struct file) *
CONFIG_NFILE_DESCRIPTORS_PER_BLOCK);
if (files[i] == NULL)
{
while (--i >= list->fl_rows)
while (--i >= orig_rows)
{
kmm_free(files[i]);
}
Expand Down

0 comments on commit 2a8c023

Please sign in to comment.