sched/group: Preserve the shared kernel group on init failure.

Kernel threads use the statically allocated g_kthread_group. If initialization of the first kernel thread fails, the common error path currently passes that static object to kmm_free(), corrupting the kernel heap.

Only free dynamically allocated task groups and detach the failed group from the TCB before returning.

Assisted-by: OpenAI Codex
Signed-off-by: yushuailong <yyyusl@qq.com>
This commit is contained in:
yushuailong 2026-09-26 15:18:37 +08:00 • committed by Xiang Xiao
parent 008521df5c
commit 84f363d79d

View file

@ -287,7 +287,12 @@ errout_with_group:
}
#endif
kmm_free(group);
if (group != &g_kthread_group)
{
kmm_free(group);
}
tcb->group = NULL;
return ret;
}