lib: sbi: Add missing sscrind and sscfg extensions in sbi_hart_ext[]
authorClément Léger <cleger@rivosinc.com>
Wed, 20 Mar 2024 14:50:43 +0000 (15:50 +0100)
committerAnup Patel <anup@brainfault.org>
Wed, 10 Apr 2024 04:03:58 +0000 (09:33 +0530)
The sbi_hart_ext[] array is missing these two extensions ids. It is
expected that this array contains all the extensions declaration at the
same index of the SBI_HART_EXT_* define. Without this, when adding a new
extension, there is a mismatch between ids and extension names and it
can even display corrupted extension names.

Addresses-Coverity-ID: 1584994 Out-of-bounds read
Fixes: 6bb6b61c27eb ("lib: sbi: Add support for smcsrind and smcdeleg")
Signed-off-by: Clément Léger <cleger@rivosinc.com>
Reviewed-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Reviewed-by: Anup Patel <anup@brainfault.org>
lib/sbi/sbi_hart.c

index 3d1369441c05750d6ea08b8ceae1a18e081560b7..0e7b5d1d7cbe32b3b2e0e736ca632ff122eaea73 100644 (file)
@@ -666,8 +666,13 @@ const struct sbi_hart_ext_data sbi_hart_ext[] = {
        __SBI_HART_EXT_DATA(sdtrig, SBI_HART_EXT_SDTRIG),
        __SBI_HART_EXT_DATA(smcsrind, SBI_HART_EXT_SMCSRIND),
        __SBI_HART_EXT_DATA(smcdeleg, SBI_HART_EXT_SMCDELEG),
+       __SBI_HART_EXT_DATA(sscsrind, SBI_HART_EXT_SSCSRIND),
+       __SBI_HART_EXT_DATA(ssccfg, SBI_HART_EXT_SSCCFG),
 };
 
+_Static_assert(SBI_HART_EXT_MAX == array_size(sbi_hart_ext),
+              "sbi_hart_ext[]: wrong number of entries");
+
 /**
  * Get the hart extensions in string format
  *