[PATCH v2] lib: sbi: sbi_ecall: Check the range of SBI error

Anup Patel anup at brainfault.org
Sun Feb 26 22:23:42 PST 2023


On Wed, Feb 22, 2023 at 8:19 AM Yu Chien Peter Lin
<peterlin at andestech.com> wrote:
>
> We should also check if the return error code is greater than 0
> (SBI_SUCCESS), as this is an invalid error.
>
> Signed-off-by: Yu Chien Peter Lin <peterlin at andestech.com>
> Reviewed-by: Xiang W <wxjstz at 126.com>

Looks good to me.

Reviewed-by: Anup Patel <anup at brainfault.org>

Applied this patch to the riscv/opensbi repo.

Thanks,
Anup

> ---
> Changes v1 -> v2:
> - Include Xiang's Reviewed-by
> - Drop the 'ret -> out_err' rename
> ---
>  lib/sbi/sbi_ecall.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/lib/sbi/sbi_ecall.c b/lib/sbi/sbi_ecall.c
> index 27ce5d49..d0f01665 100644
> --- a/lib/sbi/sbi_ecall.c
> +++ b/lib/sbi/sbi_ecall.c
> @@ -120,7 +120,7 @@ int sbi_ecall_handler(struct sbi_trap_regs *regs)
>                 trap.epc = regs->mepc;
>                 sbi_trap_redirect(regs, &trap);
>         } else {
> -               if (ret < SBI_LAST_ERR) {
> +               if (ret < SBI_LAST_ERR || SBI_SUCCESS < ret) {
>                         sbi_printf("%s: Invalid error %d for ext=0x%lx "
>                                    "func=0x%lx\n", __func__, ret,
>                                    extension_id, func_id);
> --
> 2.34.1
>
>
> --
> opensbi mailing list
> opensbi at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/opensbi



More information about the opensbi mailing list