Skip to content

Commit 2dc99ea

Browse files
author
Paul Walmsley
committed
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: [email protected] Cc: Charlie Jenkins <[email protected]> Fixes: 377be47 ("riscv: vector: Use vlenb from DT for thead") Signed-off-by: Paul Walmsley <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 5d15d2a commit 2dc99ea

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

arch/riscv/kernel/cpufeature.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -932,9 +932,9 @@ static int has_thead_homogeneous_vlenb(void)
932932
{
933933
int cpu;
934934
u32 prev_vlenb = 0;
935-
u32 vlenb;
935+
u32 vlenb = 0;
936936

937-
/* Ignore thead,vlenb property if xtheavector is not enabled in the kernel */
937+
/* Ignore thead,vlenb property if xtheadvector is not enabled in the kernel */
938938
if (!IS_ENABLED(CONFIG_RISCV_ISA_XTHEADVECTOR))
939939
return 0;
940940

0 commit comments

Comments
 (0)