mirror of
https://github.com/apache/nuttx.git
synced 2025-12-11 12:57:57 +08:00
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:
@@ -269,7 +269,7 @@ static mqd_t nxmq_vopen(FAR const char *mq_name, int oflags, va_list ap)
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = files_allocate(mq.f_inode, mq.f_oflags, mq.f_pos, 0);
|
||||
ret = files_allocate(mq.f_inode, mq.f_oflags, mq.f_pos, mq.f_priv, 0);
|
||||
if (ret < 0)
|
||||
{
|
||||
file_mq_close(&mq);
|
||||
|
||||
Reference in New Issue
Block a user