aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorDavid Rientjes <rientjes@google.com>2011-02-07 17:08:53 -0500
committerIngo Molnar <mingo@elte.hu>2011-02-14 07:29:27 -0500
commit14392fd329eca9b59d51c0aa5d0acfb4965424d1 (patch)
tree8008ec19841352f00ef82cdd338bae1fd5088245 /arch
parentb366801c95bdbeda811ac9668a3943051a18c188 (diff)
x86, numa: Add error handling for bad cpu-to-node mappings
CONFIG_DEBUG_PER_CPU_MAPS may return NUMA_NO_NODE when an early_cpu_to_node() mapping hasn't been initialized. In such a case, it emits a warning and continues without an issue but callers may try to use the return value to index into an array. We can catch those errors and fail silently since a warning has already been emitted. No current user of numa_add_cpu() requires this error checking to avoid a crash, but it's better to be proactive in case a future user happens to have a bug and a user tries to diagnose it with CONFIG_DEBUG_PER_CPU_MAPS. Reported-by: Jesper Juhl <jj@chaosbits.net> Signed-off-by: David Rientjes <rientjes@google.com> Cc: Tejun Heo <tj@kernel.org> LKML-Reference: <alpine.DEB.2.00.1102071407250.7812@chino.kir.corp.google.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'arch')
-rw-r--r--arch/x86/mm/numa.c4
-rw-r--r--arch/x86/mm/numa_64.c4
2 files changed, 8 insertions, 0 deletions
diff --git a/arch/x86/mm/numa.c b/arch/x86/mm/numa.c
index bf60715bd1b7..9559d360fde7 100644
--- a/arch/x86/mm/numa.c
+++ b/arch/x86/mm/numa.c
@@ -219,6 +219,10 @@ struct cpumask __cpuinit *debug_cpumask_set_cpu(int cpu, int enable)
219 struct cpumask *mask; 219 struct cpumask *mask;
220 char buf[64]; 220 char buf[64];
221 221
222 if (node == NUMA_NO_NODE) {
223 /* early_cpu_to_node() already emits a warning and trace */
224 return NULL;
225 }
222 mask = node_to_cpumask_map[node]; 226 mask = node_to_cpumask_map[node];
223 if (!mask) { 227 if (!mask) {
224 pr_err("node_to_cpumask_map[%i] NULL\n", node); 228 pr_err("node_to_cpumask_map[%i] NULL\n", node);
diff --git a/arch/x86/mm/numa_64.c b/arch/x86/mm/numa_64.c
index f548fbf75f44..3f9411ed3cdc 100644
--- a/arch/x86/mm/numa_64.c
+++ b/arch/x86/mm/numa_64.c
@@ -709,6 +709,10 @@ static void __cpuinit numa_set_cpumask(int cpu, int enable)
709 struct cpumask *mask; 709 struct cpumask *mask;
710 int i; 710 int i;
711 711
712 if (node == NUMA_NO_NODE) {
713 /* early_cpu_to_node() already emits a warning and trace */
714 return;
715 }
712 for_each_online_node(i) { 716 for_each_online_node(i) {
713 unsigned long addr; 717 unsigned long addr;
714 718