All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] sched_ext: Fix the memleak for sch->helper objects
@ 2025-12-08 11:23 Zqiang
  2025-12-08 11:23 ` [PATCH] sched_ext: Fix lockdep warnings in the ops_dump_init() Zqiang
  2025-12-08 17:12 ` [PATCH] sched_ext: Fix the memleak for sch->helper objects Tejun Heo
  0 siblings, 2 replies; 5+ messages in thread
From: Zqiang @ 2025-12-08 11:23 UTC (permalink / raw)
  To: tj, void, arighi, changwoo; +Cc: sched-ext, linux-kernel, qiang.zhang

This commit use kthread_destroy_worker() to release sch->helper
objects to fix the following kmemleak:

unreferenced object 0xffff888121ec7b00 (size 128):
  comm "scx_simple", pid 1197, jiffies 4295884415
  hex dump (first 32 bytes):
    00 00 00 00 00 00 00 00 00 00 00 00 ad 4e ad de  .............N..
    ff ff ff ff 00 00 00 00 ff ff ff ff ff ff ff ff  ................
  backtrace (crc 587b3352):
    kmemleak_alloc+0x62/0xa0
    __kmalloc_cache_noprof+0x28d/0x3e0
    kthread_create_worker_on_node+0xd5/0x1f0
    scx_enable.isra.210+0x6c2/0x25b0
    bpf_scx_reg+0x12/0x20
    bpf_struct_ops_link_create+0x2c3/0x3b0
    __sys_bpf+0x3102/0x4b00
    __x64_sys_bpf+0x79/0xc0
    x64_sys_call+0x15d9/0x1dd0
    do_syscall_64+0xf0/0x470
    entry_SYSCALL_64_after_hwframe+0x77/0x7f

Signed-off-by: Zqiang <qiang.zhang@linux.dev>
---
 kernel/sched/ext.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/sched/ext.c b/kernel/sched/ext.c
index df00df359067..59fa391636c7 100644
--- a/kernel/sched/ext.c
+++ b/kernel/sched/ext.c
@@ -3516,7 +3516,7 @@ static void scx_sched_free_rcu_work(struct work_struct *work)
 	int node;
 
 	irq_work_sync(&sch->error_irq_work);
-	kthread_stop(sch->helper->task);
+	kthread_destroy_worker(sch->helper);
 
 	free_percpu(sch->pcpu);
 
@@ -4508,7 +4508,7 @@ static struct scx_sched *scx_alloc_and_add_sched(struct sched_ext_ops *ops)
 	return sch;
 
 err_stop_helper:
-	kthread_stop(sch->helper->task);
+	kthread_destroy_worker(sch->helper);
 err_free_pcpu:
 	free_percpu(sch->pcpu);
 err_free_gdsqs:
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2025-12-08 17:12 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-08 11:23 [PATCH] sched_ext: Fix the memleak for sch->helper objects Zqiang
2025-12-08 11:23 ` [PATCH] sched_ext: Fix lockdep warnings in the ops_dump_init() Zqiang
2025-12-08 11:29   ` Christian Loehle
2025-12-08 13:25     ` Zqiang
2025-12-08 17:12 ` [PATCH] sched_ext: Fix the memleak for sch->helper objects Tejun Heo

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.