mirror of
https://github.com/apache/nuttx.git
synced 2026-09-24 08:45:04 +08:00
sched/environ: Serialize clearenv updates.
Protect the environment release in clearenv() with the task group mutex. This prevents concurrent environment operations from racing with cleanup. Assisted-by: OpenAI Codex Signed-off-by: yushuailong <yyyusl@qq.com>
This commit is contained in:
@@ -60,9 +60,13 @@
|
||||
int clearenv(void)
|
||||
{
|
||||
FAR struct tcb_s *tcb = this_task();
|
||||
DEBUGASSERT(tcb->group);
|
||||
FAR struct task_group_s *group = tcb->group;
|
||||
|
||||
env_release(tcb->group);
|
||||
DEBUGASSERT(group);
|
||||
|
||||
nxrmutex_lock(&group->tg_mutex);
|
||||
env_release(group);
|
||||
nxrmutex_unlock(&group->tg_mutex);
|
||||
return OK;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user