Skip to content

Commit 2a8c023

Browse files
Donny9xiaoxiang781216
authored andcommitted
fs/inode: using orig_row to ensure correct free logic
Signed-off-by: dongjiuzhu1 <[email protected]>
1 parent 6542806 commit 2a8c023

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

fs/inode/fs_files.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -90,33 +90,32 @@ static int files_extend(FAR struct filelist *list, size_t row)
9090
int i;
9191
int j;
9292

93-
if (row <= list->fl_rows)
93+
orig_rows = list->fl_rows;
94+
if (row <= orig_rows)
9495
{
9596
return 0;
9697
}
9798

98-
if (files_countlist(list) > OPEN_MAX)
99+
if (CONFIG_NFILE_DESCRIPTORS_PER_BLOCK * orig_rows > OPEN_MAX)
99100
{
100101
return -EMFILE;
101102
}
102103

103-
orig_rows = list->fl_rows;
104-
105104
files = kmm_malloc(sizeof(FAR struct file *) * row);
106105
DEBUGASSERT(files);
107106
if (files == NULL)
108107
{
109108
return -ENFILE;
110109
}
111110

112-
i = list->fl_rows;
111+
i = orig_rows;
113112
do
114113
{
115114
files[i] = kmm_zalloc(sizeof(struct file) *
116115
CONFIG_NFILE_DESCRIPTORS_PER_BLOCK);
117116
if (files[i] == NULL)
118117
{
119-
while (--i >= list->fl_rows)
118+
while (--i >= orig_rows)
120119
{
121120
kmm_free(files[i]);
122121
}

0 commit comments

Comments
 (0)