From 84f363d79d710780592253e4e08638cb3bcee9c2 Mon Sep 17 00:00:00 2001 From: yushuailong Date: Sat, 26 Sep 2026 15:18:37 +0800 Subject: [PATCH] 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 --- sched/group/group_create.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/sched/group/group_create.c b/sched/group/group_create.c index ed23dfc966b..71e288c7bd8 100644 --- a/sched/group/group_create.c +++ b/sched/group/group_create.c @@ -287,7 +287,12 @@ errout_with_group: } #endif - kmm_free(group); + if (group != &g_kthread_group) + { + kmm_free(group); + } + + tcb->group = NULL; return ret; }