sched/environ: Serialize clearenv updates.
Some checks are pending
MemBrowse Memory Report / changes-filter (push) Waiting to run
MemBrowse Memory Report / load-targets (push) Waiting to run
MemBrowse Memory Report / identical (push) Blocked by required conditions
MemBrowse Memory Report / analyze (push) Blocked by required conditions

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-08 20:16:43 +08:00 committed by Xiang Xiao
parent 69061ea246
commit dc4c846d32

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;
}