lib: sbi: sbi_ecall: Check the range of SBI error
PATCH v2 1/1 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.
---
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(-)
lib/sbi/sbi_ecall.c +1 -1
@@ -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);
Signature · 1 line
2.34.1
PATCH v2 1/1 lib: sbi: sbi_ecall: Check the range of SBI error
Quoted 9 lines · Yu Chien Peter Lin
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]>---
Changes v1 -> v2:
- Include Xiang's Reviewed-by
- Drop the 'ret ->out_err' rename
The SBI_ENOTSUPP -> SBI_ERR_NOT_SUPPORTED rename was also dropped, but as Anup suggests, we should probably do a full rework of that in another series later.
Thanks,
drew
Quoted 20 lines
--- lib/sbi/sbi_ecall.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)lib/sbi/sbi_ecall.c +1
-1@@ -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);Signature · 1 line
2.34.1
PATCH v2 1/1 lib: sbi: sbi_ecall: Check the range of SBI error
Hi Andrew,
Quoted 11 lines · Andrew Jones
Quoted 9 lines · Yu Chien Peter Lin
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]>---
Changes v1 -> v2:
- Include Xiang's Reviewed-by
- Drop the 'ret ->out_err' rename
Quoted 8 lines
The
SBI_ENOTSUPP->SBI_ERR_NOT_SUPPORTEDrename was also dropped, but as Anup suggests, we should probably do a full rework of that in another series later.Reviewed-by Andrew Jones <[email protected]>Thanks,
drew
Agreed, thanks for the review.
Best regards,
Peter Lin
Quoted 21 lines
Quoted 21 lines
--- lib/sbi/sbi_ecall.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)lib/sbi/sbi_ecall.c +1
-1@@ -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);Signature · 1 line
2.34.1
Anup Patel
AppliedPATCH v2 1/1 lib: sbi: sbi_ecall: Check the range of SBI error
In reply to Yu Chien Peter LinQuoted 6 lines · Yu Chien Peter Lin
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]>
Looks good to me.
Applied this patch to the riscv/opensbi repo.
Thanks,
Anup
Quoted 29 lines
---
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(-)lib/sbi/sbi_ecall.c +1
-2@@ -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