Commit b0101cc
sched_ext: fix uninitialized ret on alloc_percpu() failure
Smatch reported:
kernel/sched/ext.c:5332 scx_alloc_and_add_sched() warn: passing zero to 'ERR_PTR'
In scx_alloc_and_add_sched(), the alloc_percpu() failure path jumps to
err_free_gdsqs without initializing @ret. That can lead to returning
ERR_PTR(0), which violates the ERR_PTR() convention and confuses
callers.
Set @ret to -ENOMEM before jumping to the error path when
alloc_percpu() fails.
Reported-by: kernel test robot <[email protected]>
Closes: https://lore.kernel.org/r/[email protected]/
Reported-by: Dan Carpenter <[email protected]>
Fixes: c201ea1 ("sched_ext: Move event_stats_cpu into scx_sched")
Signed-off-by: Liang Jie <[email protected]>
Reviewed-by: Emil Tsalapatis <[email protected]>
Reviewed-by: Andrea Righi <[email protected]>
Signed-off-by: Tejun Heo <[email protected]>1 parent bb27226 commit b0101cc
1 file changed
Lines changed: 3 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4783 | 4783 | | |
4784 | 4784 | | |
4785 | 4785 | | |
4786 | | - | |
| 4786 | + | |
| 4787 | + | |
4787 | 4788 | | |
| 4789 | + | |
4788 | 4790 | | |
4789 | 4791 | | |
4790 | 4792 | | |
| |||
0 commit comments