]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
RISC-V: Compare cpuid with NR_CPUS before mapping.
authorAtish Patra <atish.patra@wdc.com>
Fri, 22 Feb 2019 19:41:39 +0000 (11:41 -0800)
committerPalmer Dabbelt <palmer@sifive.com>
Mon, 4 Mar 2019 18:40:39 +0000 (10:40 -0800)
We should never have a cpuid greater that NR_CPUS. Compare with NR_CPUS
before creating the mapping between logical and physical CPU ids. This
is also mandatory as NR_CPUS check is removed from
riscv_of_processor_hartid.

Signed-off-by: Atish Patra <atish.patra@wdc.com>
Reviewed-by: Anup Patel <anup@brainfault.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Palmer Dabbelt <palmer@sifive.com>
arch/riscv/kernel/smpboot.c

index d369b669fe043dd39b579021f751bd2c9d55ed0d..eb533b5c2c8c04d6552664439602fcd204748b0c 100644 (file)
@@ -66,6 +66,11 @@ void __init setup_smp(void)
                        found_boot_cpu = 1;
                        continue;
                }
+               if (cpuid >= NR_CPUS) {
+                       pr_warn("Invalid cpuid [%d] for hartid [%d]\n",
+                               cpuid, hart);
+                       break;
+               }
 
                cpuid_to_hartid_map(cpuid) = hart;
                set_cpu_possible(cpuid, true);