]> git.ipfire.org Git - thirdparty/linux.git/commit
sched_ext: Fix uninitialized ret in scx_alloc_and_add_sched()
authorCheng-Yang Chou <yphbchou0911@gmail.com>
Sat, 14 Mar 2026 01:39:34 +0000 (09:39 +0800)
committerTejun Heo <tj@kernel.org>
Sat, 14 Mar 2026 09:00:53 +0000 (23:00 -1000)
commite36bc38ebfac95ecd088d4bc0ceb3ffcef2ebdfa
tree94f201b97ee3f37a9faaa7548cc22c9ed72b0056
parent12b49dd15e4bf4e906759ac445797ba2213e52dd
sched_ext: Fix uninitialized ret in scx_alloc_and_add_sched()

Under CONFIG_EXT_SUB_SCHED, the kzalloc() and kstrdup() failure
paths jump to err_stop_helper without first setting ret. The
function then returns ERR_PTR(ret) with ret uninitialized, which
can produce ERR_PTR(0) (NULL), causing the caller's IS_ERR() check
to pass and leading to a NULL pointer dereference.

Set ret = -ENOMEM before each goto to fix the error path.

Fixes: ebeca1f930ea ("sched_ext: Introduce cgroup sub-sched support")
Signed-off-by: Cheng-Yang Chou <yphbchou0911@gmail.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
kernel/sched/ext.c