提交 5c44571b 编写于 作者: P Peng Fan 提交者: Yang Yingliang

percpu: use nr_groups as check condition

mainline inclusion
from mainline-5.1-rc1
commit 2de7852f
category: bugfix
bugzilla: 34611
CVE: NA

-------------------------------------------------
group_cnt array is defined with NR_CPUS entries, but normally
nr_groups will not reach up to NR_CPUS. So there is no issue
to the current code.

Checking other parts of pcpu_build_alloc_info, use nr_groups as
check condition, so make it consistent to use 'group < nr_groups'
as for loop check. In case we do have nr_groups equals with NR_CPUS,
we could also avoid memory access out of bounds.
Signed-off-by: NPeng Fan <peng.fan@nxp.com>
Signed-off-by: NDennis Zhou <dennis@kernel.org>
(cherry picked from commit 2de7852f)
Signed-off-by: NKefeng Wang <wangkefeng.wang@huawei.com>
Signed-off-by: NLiu Shixin <liushixin2@huawei.com>
Reviewed-by: NKefeng Wang <wangkefeng.wang@huawei.com>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 9e845639
...@@ -2387,7 +2387,7 @@ static struct pcpu_alloc_info * __init pcpu_build_alloc_info( ...@@ -2387,7 +2387,7 @@ static struct pcpu_alloc_info * __init pcpu_build_alloc_info(
ai->atom_size = atom_size; ai->atom_size = atom_size;
ai->alloc_size = alloc_size; ai->alloc_size = alloc_size;
for (group = 0, unit = 0; group_cnt[group]; group++) { for (group = 0, unit = 0; group < nr_groups; group++) {
struct pcpu_group_info *gi = &ai->groups[group]; struct pcpu_group_info *gi = &ai->groups[group];
/* /*
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册