diff options
author | Atish Patra <atish.patra@wdc.com> | 2019-02-22 20:41:39 +0100 |
---|---|---|
committer | Palmer Dabbelt <palmer@sifive.com> | 2019-03-04 19:40:39 +0100 |
commit | 291debb38dbbce9d5e7c342c5d6dc616f1d9777e (patch) | |
tree | 7850ccf161b2297e325d93a5807f9543caadda64 /arch/riscv | |
parent | RISC-V: Allow hartid-to-cpuid function to fail. (diff) | |
download | linux-291debb38dbbce9d5e7c342c5d6dc616f1d9777e.tar.xz linux-291debb38dbbce9d5e7c342c5d6dc616f1d9777e.zip |
RISC-V: Compare cpuid with NR_CPUS before mapping.
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>
Diffstat (limited to 'arch/riscv')
-rw-r--r-- | arch/riscv/kernel/smpboot.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/arch/riscv/kernel/smpboot.c b/arch/riscv/kernel/smpboot.c index d369b669fe04..eb533b5c2c8c 100644 --- a/arch/riscv/kernel/smpboot.c +++ b/arch/riscv/kernel/smpboot.c @@ -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); |