aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/kernel
diff options
context:
space:
mode:
authorLorenzo Pieralisi <lorenzo.pieralisi@arm.com>2012-11-22 12:02:54 -0500
committerRussell King <rmk+kernel@arm.linux.org.uk>2012-11-23 08:01:31 -0500
commitce7b175656a1903605f0184bf33acebff70bfe7f (patch)
tree79e95b84564053c728f0ed285908cc0d20ecf8b9 /arch/arm/kernel
parentc7cc504bc351e41e871e317ca7f032f4562f34ad (diff)
ARM: 7585/1: kernel: fix nr_cpu_ids check in DT logical map init
If a kernel is configured with a DT containing more /cpu nodes than nr_cpu_ids, the number of cpus must be capped in the DT parsing code. Current code carries out the check, but fails to cap the value and the check is executed after the cpu logical index is used, which can lead to memory corruption due to index overflow. This patch refactors the check against nr_cpu_ids and move it before any computed index is used in the parsing code. Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com> Acked-by: Grant Likely <grant.likely@secretlab.ca> Reported-by: Mark Rutland <mark.rutland@arm.com> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'arch/arm/kernel')
-rw-r--r--arch/arm/kernel/devtree.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/arch/arm/kernel/devtree.c b/arch/arm/kernel/devtree.c
index aaf9add497fe..70f1bdeb241b 100644
--- a/arch/arm/kernel/devtree.c
+++ b/arch/arm/kernel/devtree.c
@@ -139,10 +139,14 @@ void __init arm_dt_init_cpu_maps(void)
139 i = cpuidx++; 139 i = cpuidx++;
140 } 140 }
141 141
142 tmp_map[i] = hwid; 142 if (WARN(cpuidx > nr_cpu_ids, "DT /cpu %u nodes greater than "
143 143 "max cores %u, capping them\n",
144 if (cpuidx > nr_cpu_ids) 144 cpuidx, nr_cpu_ids)) {
145 cpuidx = nr_cpu_ids;
145 break; 146 break;
147 }
148
149 tmp_map[i] = hwid;
146 } 150 }
147 151
148 if (WARN(!bootcpu_valid, "DT missing boot CPU MPIDR[23:0], " 152 if (WARN(!bootcpu_valid, "DT missing boot CPU MPIDR[23:0], "