]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
sched_ext: Use kobject_put() for kobject_init_and_add() failure in scx_alloc_and_add_...
authorTejun Heo <tj@kernel.org>
Mon, 16 Mar 2026 05:43:28 +0000 (19:43 -1000)
committerTejun Heo <tj@kernel.org>
Mon, 16 Mar 2026 09:27:04 +0000 (23:27 -1000)
commit618a9db0158b1c51fd33822cf804f5a09f829837
treed32501b90bc0f9b2df42c518c63f435eb37b77ff
parent0c66b0da006415880444ec821e3cb66a89273865
sched_ext: Use kobject_put() for kobject_init_and_add() failure in scx_alloc_and_add_sched()

kobject_init_and_add() failure requires kobject_put() for proper cleanup, but
the error paths were using kfree(sch) possibly leaking the kobject name. The
kset_create_and_add() failure was already using kobject_put() correctly.

Switch the kobject_init_and_add() error paths to use kobject_put(). As the
release path puts the cgroup ref, make scx_alloc_and_add_sched() always
consume @cgrp via a new err_put_cgrp label at the bottom of the error chain
and update scx_sub_enable_workfn() accordingly.

Fixes: 17108735b47d ("sched_ext: Use dynamic allocation for scx_sched")
Reported-by: David Carlier <devnexen@gmail.com>
Link: https://lore.kernel.org/r/20260314134457.46216-1-devnexen@gmail.com
Signed-off-by: Tejun Heo <tj@kernel.org>
Reviewed-by: Andrea Righi <arighi@nvidia.com>
kernel/sched/ext.c