lib: sbi: Ensure domidx_to_domain_table is null-terminated
PATCH 1/1 lib: sbi: Ensure domidx_to_domain_table is null-terminated
sbi_domain_for_each() requires domidx_to_domain_table[] to be null-terminated. Allocate one extra element which will always be null.
Signed-off-by Andrew Jones <[email protected]>
--- lib/sbi/sbi_domain.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
lib/sbi/sbi_domain.c +5 -1
@@ -17,8 +17,12 @@#include <sbi/sbi_scratch.h> #include <sbi/sbi_string.h> +/* +* We allocate an extra element because sbi_domain_for_each() expects +* the array to be null-terminated. +*/ +struct sbi_domain *domidx_to_domain_table[SBI_DOMAIN_MAX_INDEX +1 ] = {0 };struct sbi_domain *hartid_to_domain_table[SBI_HARTMASK_MAX_BITS ] = {0 }; -struct sbi_domain *domidx_to_domain_table[SBI_DOMAIN_MAX_INDEX ] = {0 };static u32 domain_count =0 ;static bool domain_finalized = false;
Signature · 1 line
2.39.1
Anup Patel
AppliedPATCH 1/1 lib: sbi: Ensure domidx_to_domain_table is null-terminated
Quoted 6 lines · Andrew Jones
sbi_domain_for_each()requires domidx_to_domain_table[] to be null-terminated. Allocate one extra element which will always be null.Signed-off-by Andrew Jones <[email protected]>
Looks good to me.
Reviewed-by Anup Patel <[email protected]>
Applied this patch to the riscv/opensbi repo.
Thanks,
Anup
Quoted 30 lines
--- lib/sbi/sbi_domain.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)lib/sbi/sbi_domain.c +5
-2@@ -17,8 +17,12 @@#include <sbi/sbi_scratch.h> #include <sbi/sbi_string.h> +/* +* We allocate an extra element because sbi_domain_for_each() expects +* the array to be null-terminated. +*/ +struct sbi_domain *domidx_to_domain_table[SBI_DOMAIN_MAX_INDEX +1 ] = {0 };struct sbi_domain *hartid_to_domain_table[SBI_HARTMASK_MAX_BITS ] = {0 }; -struct sbi_domain *domidx_to_domain_table[SBI_DOMAIN_MAX_INDEX ] = {0 };static u32 domain_count =0 ;static bool domain_finalized = false; --2.39.1
--
opensbi mailing list
opensbi at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/opensbi