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:
yushuailong
2026-09-09 10:22:01 +08:00
committed by Xiang Xiao
parent 69061ea246
commit dc4c846d32
+6 -2
View File
@@ -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;
}