Skip to content

Commit 48c153d

Browse files
anjiahao1xiaoxiang781216
authored andcommitted
vfs:add nxsched_foreach to sched_lock avoid crash
If scheduling occurs in file_fsync, fl_lock may be released, and an error may occur when calling nxmutex_unlock Signed-off-by: anjiahao <[email protected]>
1 parent fa63ef6 commit 48c153d

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

sched/sched/sched_foreach.c

+2
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ void nxsched_foreach(nxsched_foreach_t handler, FAR void *arg)
6363
/* Visit each active task */
6464

6565
flags = enter_critical_section();
66+
sched_lock();
6667
for (ndx = 0; ndx < g_npidhash; ndx++)
6768
{
6869
/* This test and the function call must be atomic */
@@ -73,5 +74,6 @@ void nxsched_foreach(nxsched_foreach_t handler, FAR void *arg)
7374
}
7475
}
7576

77+
sched_unlock();
7678
leave_critical_section(flags);
7779
}

0 commit comments

Comments
 (0)