[PATCH 1/3] lib: fix is_region_valid()
Heinrich Schuchardt
heinrich.schuchardt at canonical.com
Wed Dec 7 06:07:49 PST 2022
For 'reg->order == __riscv_xlen' the term 'BIT(reg->order)' is undefined.
Addresses-Coverity-ID: 1529706 ("Bad bit shift operation")
Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt at canonical.com>
---
lib/sbi/sbi_domain.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/lib/sbi/sbi_domain.c b/lib/sbi/sbi_domain.c
index 3302213..52ae1a1 100644
--- a/lib/sbi/sbi_domain.c
+++ b/lib/sbi/sbi_domain.c
@@ -146,11 +146,12 @@ static bool is_region_valid(const struct sbi_domain_memregion *reg)
if (reg->order < 3 || __riscv_xlen < reg->order)
return FALSE;
- if (reg->order == __riscv_xlen && reg->base != 0)
- return FALSE;
-
- if (reg->base & (BIT(reg->order) - 1))
+ if (reg->order == __riscv_xlen) {
+ if (reg->base != 0)
+ return FALSE;
+ } else if (reg->base & (BIT(reg->order) - 1)) {
return FALSE;
+ }
return TRUE;
}
--
2.37.2
More information about the opensbi
mailing list