summaryrefslogtreecommitdiffstats
path: root/mm
diff options
context:
space:
mode:
authorPeng Fan <peng.fan@nxp.com>2019-02-20 14:32:55 +0100
committerDennis Zhou <dennis@kernel.org>2019-02-23 23:36:53 +0100
commit2de7852fe9096e92c5f10faa472550a2a7121cea (patch)
treecde1e86e79d9b743875d9cf9dbb738d3d6a83bfb /mm
parentLinux 5.0-rc7 (diff)
downloadlinux-2de7852fe9096e92c5f10faa472550a2a7121cea.tar.xz
linux-2de7852fe9096e92c5f10faa472550a2a7121cea.zip
percpu: use nr_groups as check condition
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: Peng Fan <peng.fan@nxp.com> Signed-off-by: Dennis Zhou <dennis@kernel.org>
Diffstat (limited to 'mm')
-rw-r--r--mm/percpu.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/mm/percpu.c b/mm/percpu.c
index db86282fd024..c5c750781628 100644
--- a/mm/percpu.c
+++ b/mm/percpu.c
@@ -2384,7 +2384,7 @@ static struct pcpu_alloc_info * __init pcpu_build_alloc_info(
ai->atom_size = atom_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];
/*