Skip to content

Commit c167ea8

Browse files
committed
lkl: Fix memory leak of TIF_HOST_THREAD threads
Now the TIF_HOST_THREAD threads are not properly killed. Signed-off-by: Yuan Liu <[email protected]>
1 parent 8e4ddea commit c167ea8

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

arch/lkl/kernel/setup.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ int __init lkl_start_kernel(struct lkl_host_operations *ops,
7575
}
7676

7777
lkl_ops->sem_down(init_sem);
78+
lkl_ops->sem_free(init_sem);
7879
current_thread_info()->tid = lkl_ops->thread_self();
7980
lkl_cpu_change_owner(current_thread_info()->tid);
8081

arch/lkl/kernel/threads.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -232,16 +232,16 @@ void threads_cnt_dec(void)
232232

233233
void threads_cleanup(void)
234234
{
235-
struct task_struct *p;
235+
struct task_struct *p, *t;
236236

237-
for_each_process(p) {
238-
struct thread_info *ti = task_thread_info(p);
237+
for_each_process_thread(p, t) {
238+
struct thread_info *ti = task_thread_info(t);
239239

240-
if (p->pid != 1)
241-
WARN(!(p->flags & PF_KTHREAD),
242-
"non kernel thread task %p\n", p->comm);
243-
WARN(p->state == TASK_RUNNING,
244-
"thread %s still running while halting\n", p->comm);
240+
if (t->pid != 1 && !test_ti_thread_flag(ti, TIF_HOST_THREAD))
241+
WARN(!(t->flags & PF_KTHREAD),
242+
"non kernel thread task %s\n", t->comm);
243+
WARN(t->state == TASK_RUNNING,
244+
"thread %s still running while halting\n", t->comm);
245245

246246
kill_thread(ti);
247247
}

0 commit comments

Comments
 (0)