mirror of
https://github.com/torvalds/linux.git
synced 2026-05-13 00:28:54 +02:00
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: ebeca1f930 ("sched_ext: Introduce cgroup sub-sched support")
Signed-off-by: Cheng-Yang Chou <yphbchou0911@gmail.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
This commit is contained in:
parent
12b49dd15e
commit
e36bc38ebf
|
|
@ -6444,13 +6444,17 @@ static struct scx_sched *scx_alloc_and_add_sched(struct sched_ext_ops *ops,
|
|||
|
||||
#ifdef CONFIG_EXT_SUB_SCHED
|
||||
char *buf = kzalloc(PATH_MAX, GFP_KERNEL);
|
||||
if (!buf)
|
||||
if (!buf) {
|
||||
ret = -ENOMEM;
|
||||
goto err_stop_helper;
|
||||
}
|
||||
cgroup_path(cgrp, buf, PATH_MAX);
|
||||
sch->cgrp_path = kstrdup(buf, GFP_KERNEL);
|
||||
kfree(buf);
|
||||
if (!sch->cgrp_path)
|
||||
if (!sch->cgrp_path) {
|
||||
ret = -ENOMEM;
|
||||
goto err_stop_helper;
|
||||
}
|
||||
|
||||
sch->cgrp = cgrp;
|
||||
INIT_LIST_HEAD(&sch->children);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user