linux/arch/riscv
Paul Walmsley 66bc9c2307 riscv: hwprobe: avoid uninitialized variable use in hwprobe_arch_id()
[ Upstream commit b7776a802f ]

Resolve this smatch warning:

  arch/riscv/kernel/sys_hwprobe.c:50 hwprobe_arch_id() error: uninitialized symbol 'cpu_id'.

This could happen if hwprobe_arch_id() was called with a key ID of
something other than MVENDORID, MIMPID, and MARCHID.  This does not
happen in the current codebase.  The only caller of hwprobe_arch_id()
is a function that only passes one of those three key IDs.

For the sake of reducing static analyzer warning noise, and in the
unlikely event that hwprobe_arch_id() is someday called with some
other key ID, validate hwprobe_arch_id()'s input to ensure that
'cpu_id' is always initialized before use.

Fixes: ea3de9ce8a ("RISC-V: Add a syscall for HW probing")
Cc: Evan Green <evan@rivosinc.com>
Signed-off-by: Paul Walmsley <pjw@kernel.org>
Link: https://lore.kernel.org/r/cf5a13ec-19d0-9862-059b-943f36107bf3@kernel.org
Signed-off-by: Sasha Levin <sashal@kernel.org>
History 2025-10-29 14:10:27 +01:00
..
boot Allwinner fixes for 6.17 2025-09-23 22:30:57 +02:00
configs soc: defconfig updates for 6.16 2025-07-29 11:27:41 -07:00
crypto lib/crypto: riscv/sha512: Migrate optimized SHA-512 code to library 2025-06-30 09:26:19 -07:00
errata RISC-V: errata: Use medany for relocatable builds 2025-03-26 15:56:37 -07:00
include RISC-V: Define pgprot_dmacoherent() for non-coherent devices 2025-10-29 14:10:27 +01:00
kernel riscv: hwprobe: avoid uninitialized variable use in hwprobe_arch_id() 2025-10-29 14:10:27 +01:00
kvm RISC-V: KVM: Write hgatp register with valid mode bits 2025-10-15 12:03:59 +02:00
lib Crypto library updates for 6.17 2025-07-28 17:58:52 -07:00
mm riscv: mm: Use mmu-type from FDT to limit SATP mode 2025-10-29 14:10:17 +01:00
net riscv, bpf: Sign extend struct ops return values properly 2025-10-15 12:03:33 +02:00
purgatory Crypto library updates for 6.17 2025-07-28 17:58:52 -07:00
tools riscv: Stop considering R_RISCV_NONE as bad relocations 2025-07-16 08:13:55 -07:00
Kbuild riscv: migrate to the generic rule for built-in DTB 2025-03-18 13:30:13 +00:00
Kconfig riscv: Only allow LTO with CMODEL_MEDANY 2025-09-04 16:25:46 -06:00
Kconfig.debug riscv: Add tests for riscv module loading 2023-11-07 14:59:32 -08:00
Kconfig.errata riscv: Add ghostwrite vulnerability 2025-01-18 12:33:39 -08:00
Kconfig.socs riscv: add Andes SoC family Kconfig support 2025-07-21 16:51:52 +02:00
Kconfig.vendor riscv: Add SiFive xsfvqmaccdod and xsfvqmaccqoq vendor extensions 2025-05-08 11:01:43 -07:00
Makefile riscv: Implement HAVE_DYNAMIC_FTRACE_WITH_CALL_OPS 2025-06-05 11:09:30 -07:00
Makefile.postlink kbuild: Create intermediate vmlinux build with relocations preserved 2025-03-17 00:29:50 +09:00