fs: Fix the race condition in file_dup

NULL inode passed to files_allocate doesn't mark file struct in the
allocated state, so other threads which invovle in file allocation
(e.g. open or dup) may allocate the same file struct again.

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: I53ff876eae3c7a1e311e7f671686b73a4b4ef891
This commit is contained in:
Xiang Xiao
2021-01-02 22:08:43 +08:00
parent 0112909453
commit 3eb62b010b
5 changed files with 20 additions and 22 deletions
+1 -1
View File
@@ -408,7 +408,7 @@ struct file
int f_oflags; /* Open mode flags */
off_t f_pos; /* File position */
FAR struct inode *f_inode; /* Driver or file system interface */
void *f_priv; /* Per file driver private data */
FAR void *f_priv; /* Per file driver private data */
};
/* This defines a list of files indexed by the file descriptor */