From: Yu Chien Peter Lin Date: Wed, 22 Feb 2023 02:48:54 +0000 (+0800) Subject: lib: sbi: sbi_ecall: Check the range of SBI error X-Git-Tag: accepted/tizen/unified/riscv/20231123.095152~57 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=67b2a408924b466dcd659c70348043987401f0b1;p=platform%2Fkernel%2Fopensbi.git lib: sbi: sbi_ecall: Check the range of SBI error 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 Reviewed-by: Xiang W Reviewed-by: Andrew Jones Reviewed-by: Anup Patel --- diff --git a/lib/sbi/sbi_ecall.c b/lib/sbi/sbi_ecall.c index 27ce5d4..d0f0166 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);