Skip to contentSkip to conversation

riscv: cpufeature: avoid uninitialized variable in has_thead_homogeneous_vlenb()

PATCH New Paul Walmsley 1 participant 1 message Oct 18, 2025 RISC-V

lore
Share & tools
lore

Paul Walmsley

author maintainer
#0 lore raw

PATCH 1/1 riscv: cpufeature: avoid uninitialized variable in has_thead_homogeneous_vlenb()

In has_thead_homogeneous_vlenb(), smatch detected that the vlenb variable could be used while uninitialized. It appears that this could happen if no CPUs described in DT have the "thead,vlenb" property.

Fix by initializing vlenb to 0, which will keep thead_vlenb_of set to 0 (as it was statically initialized). This in turn will cause riscv_v_setup_vsize() to fall back to CSR probing - the desired result if thead,vlenb isn't provided in the DT data.

While here, fix a nearby comment typo.

Cc Charlie Jenkins <[email protected]>
Fixes 377be47f90e41 ("riscv: vector: Use vlenb from DT for thead")
---
 arch/riscv/kernel/cpufeature.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/riscv/kernel/cpufeature.c +2 -2
index 67b59699357d..72ca768f4e91 100644
@@ -932,9 +932,9 @@ static int has_thead_homogeneous_vlenb(void)
 {
 	int cpu;
 	u32 prev_vlenb = 0;
-	u32 vlenb;
+	u32 vlenb = 0;
 
-	/* Ignore thead,vlenb property if xtheavector is not enabled in the kernel */
+	/* Ignore thead,vlenb property if xtheadvector is not enabled in the kernel */
 	if (!IS_ENABLED(CONFIG_RISCV_ISA_XTHEADVECTOR))
 		return 0;
 
Signature · 7 lines
2.48.1


_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv