]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
sched_ext: fix uninitialized ret on alloc_percpu() failure
authorLiang Jie <liangjie@lixiang.com>
Tue, 16 Dec 2025 09:39:55 +0000 (17:39 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 8 Jan 2026 09:16:43 +0000 (10:16 +0100)
commitf9cb8a49f7a5db234b171d78ee25b6c6c9aa6fdb
tree973e24a35b04572a2e8b0c8c976e80a69d1b408c
parent182a2786d248e5051c55e1710643e7af32a98453
sched_ext: fix uninitialized ret on alloc_percpu() failure

[ Upstream commit b0101ccb5b4641885f30fecc352ef891ed06e083 ]

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 <lkp@intel.com>
Closes: https://lore.kernel.org/r/202512141601.yAXDAeA9-lkp@intel.com/
Reported-by: Dan Carpenter <error27@gmail.com>
Fixes: c201ea1578d3 ("sched_ext: Move event_stats_cpu into scx_sched")
Signed-off-by: Liang Jie <liangjie@lixiang.com>
Reviewed-by: Emil Tsalapatis <emil@etsalapatis.com>
Reviewed-by: Andrea Righi <arighi@nvidia.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
kernel/sched/ext.c