summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorYu Chien Peter Lin <[email protected]>2023-02-22 10:48:54 +0800
committerAnup Patel <[email protected]>2023-02-27 11:46:08 +0530
commit67b2a408924b466dcd659c70348043987401f0b1 (patch)
tree4837aa60bba5f8d70134f11706f26f1af3afa5e3 /lib
parent2491242282b4e3bb0617f41dfb667ca9a8241c0a (diff)
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 <[email protected]> Reviewed-by: Xiang W <[email protected]> Reviewed-by: Andrew Jones <[email protected]> Reviewed-by: Anup Patel <[email protected]>
Diffstat (limited to 'lib')
-rw-r--r--lib/sbi/sbi_ecall.c2
1 files changed, 1 insertions, 1 deletions
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);