Re: [PATCH v2 2/9] x86: numa: check the node id consistently for x86
From: Ingo Molnar
Date: Mon Sep 02 2019 - 14:17:42 EST
* Peter Zijlstra <peterz@xxxxxxxxxxxxx> wrote:
> Also note that the CONFIG_DEBUG_PER_CPU_MAPS version of
> cpumask_of_node() already does this (although it wants the below fix).
>
> ---
> diff --git a/arch/x86/mm/numa.c b/arch/x86/mm/numa.c
> index e6dad600614c..5f49c10201c7 100644
> --- a/arch/x86/mm/numa.c
> +++ b/arch/x86/mm/numa.c
> @@ -861,7 +861,7 @@ void numa_remove_cpu(int cpu)
> */
> const struct cpumask *cpumask_of_node(int node)
> {
> - if (node >= nr_node_ids) {
> + if ((unsigned)node >= nr_node_ids) {
> printk(KERN_WARNING
> "cpumask_of_node(%d): node > nr_node_ids(%u)\n",
> node, nr_node_ids);
Nitpicking: please also fix the kernel message to say ">=".
With that:
Acked-by: Ingo Molnar <mingo@xxxxxxxxxx>
Note that:
- arch/arm64/mm/numa.c copied the same sign bug (or unrobustness if we
don't want to call it a bug).
- Kudos to the mm/memcontrol.c and kernel/bpf/syscall.c teams for not
copying that bug. Booo for none of them fixing the buggy pattern
elsewhere in the kernel ;-)
Thanks,
Ingo