fs: Move fl_lock to a more appropriate location.
reason: The list->fl_files may be modified by files_extend. If it is being modified, there will be a race condition for fl_files[l1][l2]. Signed-off-by: hujun5 <hujun5@xiaomi.com>
This commit is contained in:
parent
a307dc0608
commit
ccf477710a
1 changed files with 2 additions and 2 deletions
|
@ -73,8 +73,9 @@ static FAR struct file *files_fget_by_index(FAR struct filelist *list,
|
||||||
irqstate_t flags;
|
irqstate_t flags;
|
||||||
|
|
||||||
flags = spin_lock_irqsave(&list->fl_lock);
|
flags = spin_lock_irqsave(&list->fl_lock);
|
||||||
|
|
||||||
filep = &list->fl_files[l1][l2];
|
filep = &list->fl_files[l1][l2];
|
||||||
|
spin_unlock_irqrestore(&list->fl_lock, flags);
|
||||||
|
|
||||||
#ifdef CONFIG_FS_REFCOUNT
|
#ifdef CONFIG_FS_REFCOUNT
|
||||||
if (filep->f_inode != NULL)
|
if (filep->f_inode != NULL)
|
||||||
{
|
{
|
||||||
|
@ -110,7 +111,6 @@ static FAR struct file *files_fget_by_index(FAR struct filelist *list,
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
spin_unlock_irqrestore(&list->fl_lock, flags);
|
|
||||||
return filep;
|
return filep;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue