[PATCH v2 1/3] lib: fix is_region_valid()
Xiang W
wxjstz at 126.com
Wed Dec 7 18:30:21 PST 2022
在 2022-12-08星期四的 02:14 +0100,Heinrich Schuchardt写道:
> 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>
LGTM
Reviewed-by: Xiang W <wxjstz at 126.com>
> ---
> v2:
> Make the logical constraint a bit easier to read.
> ---
> lib/sbi/sbi_domain.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/lib/sbi/sbi_domain.c b/lib/sbi/sbi_domain.c
> index 3302213..3205595 100644
> --- a/lib/sbi/sbi_domain.c
> +++ b/lib/sbi/sbi_domain.c
> @@ -149,7 +149,7 @@ static bool is_region_valid(const struct sbi_domain_memregion *reg)
> if (reg->order == __riscv_xlen && reg->base != 0)
> return FALSE;
>
> - if (reg->base & (BIT(reg->order) - 1))
> + if (reg->order < __riscv_xlen && (reg->base & (BIT(reg->order) - 1)))
> return FALSE;
>
> return TRUE;
More information about the opensbi
mailing list