Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 14392fd3 authored by David Rientjes's avatar David Rientjes Committed by Ingo Molnar
Browse files

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: default avatarJesper Juhl <jj@chaosbits.net>
Signed-off-by: default avatarDavid 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: default avatarIngo Molnar <mingo@elte.hu>
parent b366801c
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -219,6 +219,10 @@ struct cpumask __cpuinit *debug_cpumask_set_cpu(int cpu, int enable)
	struct cpumask *mask;
	char buf[64];

	if (node == NUMA_NO_NODE) {
		/* early_cpu_to_node() already emits a warning and trace */
		return NULL;
	}
	mask = node_to_cpumask_map[node];
	if (!mask) {
		pr_err("node_to_cpumask_map[%i] NULL\n", node);
+4 −0
Original line number Diff line number Diff line
@@ -709,6 +709,10 @@ static void __cpuinit numa_set_cpumask(int cpu, int enable)
	struct cpumask *mask;
	int i;

	if (node == NUMA_NO_NODE) {
		/* early_cpu_to_node() already emits a warning and trace */
		return;
	}
	for_each_online_node(i) {
		unsigned long addr;