lkml.org 
[lkml]   [2014]   [Nov]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [PATCH] crypto: caam: fix error reporting
Date
On Friday, October 31, 2014 at 07:22:09 PM, Kim Phillips wrote:
> On Fri, 31 Oct 2014 18:57:33 +0200
>
> Cristian Stoica <cristian.stoica@freescale.com> wrote:
> > The error code returned by hardware is four bits wide with an expected
> > zero MSB. A hardware error condition where the error code can get between
> > 0x8 and 0xf will trigger an out of bound array access on the error
> > message table.
>
> If this issue was brought up by h/w, the appropriate new error codes
> should be being introduced.
>
> Otherwise, I'm assuming it was brought up by a static code analyser,
> which technically could be ignored, but...
>
> > - /*
> > - * If there is no further error handling function, just
> > - * print the error code, error string and exit. Otherwise
> > - * call the handler function.
> > - */
>
> why remove the comment? It's still valid.
>
> > - if (!status_src[ssrc].report_ssed)
> > - dev_err(jrdev, "%08x: %s: \n", status, status_src[ssrc].error);
> > - else
> > + if (status_src[ssrc].report_ssed)
> >
> > status_src[ssrc].report_ssed(jrdev, status, error);
> >
> > + else if (error)
> > + dev_err(jrdev, "%d: %s\n", ssrc, error);
> > + else
> > + dev_err(jrdev, "%d: unknown error code\n", ssrc);
>
> This is simpler:
>
> diff --git a/drivers/crypto/caam/error.c b/drivers/crypto/caam/error.c
> index 6531054..6f4a148 100644
> --- a/drivers/crypto/caam/error.c
> +++ b/drivers/crypto/caam/error.c
> @@ -224,7 +224,12 @@ void caam_jr_strstatus(struct device *jrdev, u32
> status) { report_cond_code_status, "Condition Code" },
> };
> u32 ssrc = status >> JRSTA_SSRC_SHIFT;
> - const char *error = status_src[ssrc].error;
> + const char *error;
> +
> + if (ssrc >= ARRAY_SIZE(status_src)) {
> + dev_err(jrdev, "unknown error status source %d\n", ssrc);
> + return;
> + }
>
> /*
> * If there is no further error handling function, just

This indeed makes sense.

Best regards,
Marek Vasut


\
 
 \ /
  Last update: 2014-11-01 13:21    [W:2.023 / U:0.076 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site