Skip to content

Commit ff67270

Browse files
Zqianggregkh
authored andcommitted
sched_ext: Fix the memleak for sch->helper objects
commit 517a44d upstream. 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 Fixes: bff3b5a ("sched_ext: Move disable machinery into scx_sched") Cc: stable@vger.kernel.org # v6.16+ Signed-off-by: Zqiang <qiang.zhang@linux.dev> Signed-off-by: Tejun Heo <tj@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 514d605 commit ff67270

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

kernel/sched/ext.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3512,7 +3512,7 @@ static void scx_sched_free_rcu_work(struct work_struct *work)
35123512
int node;
35133513

35143514
irq_work_sync(&sch->error_irq_work);
3515-
kthread_stop(sch->helper->task);
3515+
kthread_destroy_worker(sch->helper);
35163516

35173517
free_percpu(sch->pcpu);
35183518

@@ -4504,7 +4504,7 @@ static struct scx_sched *scx_alloc_and_add_sched(struct sched_ext_ops *ops)
45044504
return sch;
45054505

45064506
err_stop_helper:
4507-
kthread_stop(sch->helper->task);
4507+
kthread_destroy_worker(sch->helper);
45084508
err_free_pcpu:
45094509
free_percpu(sch->pcpu);
45104510
err_free_gdsqs:

0 commit comments

Comments
 (0)