OpenSBI Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Yu-Chien Peter Lin <peterlin@andestech.com>
To: opensbi@lists.infradead.org
Subject: [PATCH v2] lib: sbi: sbi_ecall: Check the range of SBI error
Date: Thu, 23 Feb 2023 10:50:40 +0000	[thread overview]
Message-ID: <Y/dFAAKyBXCCegcb@APC323> (raw)
In-Reply-To: <20230222122405.uoi2kavjdngy5q5a@orel>

Hi Andrew,

On Wed, Feb 22, 2023 at 01:24:05PM +0100, Andrew Jones wrote:
> On Wed, Feb 22, 2023 at 10:48:54AM +0800, Yu Chien Peter Lin 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@andestech.com>
> > Reviewed-by: Xiang W <wxjstz@126.com>
> > ---
> > 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.
> 
> Reviewed-by: Andrew Jones <ajones@ventanamicro.com>
> 
> Thanks,
> drew

Agreed, thanks for the review.

Best regards,
Peter Lin

> 
> > ---
> >  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
> > 


  reply	other threads:[~2023-02-23 10:50 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-22  2:48 [PATCH v2] lib: sbi: sbi_ecall: Check the range of SBI error Yu Chien Peter Lin
2023-02-22 12:24 ` Andrew Jones
2023-02-23 10:50   ` Yu-Chien Peter Lin [this message]
2023-02-27  6:23 ` Anup Patel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Y/dFAAKyBXCCegcb@APC323 \
    --to=peterlin@andestech.com \
    --cc=opensbi@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox