Commit 49783d0f authored by Cristian Stoica's avatar Cristian Stoica Committed by Herbert Xu

crypto: caam - fix error reporting

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.
This patch fixes the invalid array access following such an error and
reports the condition.
Signed-off-by: default avatarCristian Stoica <cristian.stoica@freescale.com>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent 7222d1a3
...@@ -213,27 +213,36 @@ void caam_jr_strstatus(struct device *jrdev, u32 status) ...@@ -213,27 +213,36 @@ void caam_jr_strstatus(struct device *jrdev, u32 status)
void (*report_ssed)(struct device *jrdev, const u32 status, void (*report_ssed)(struct device *jrdev, const u32 status,
const char *error); const char *error);
const char *error; const char *error;
} status_src[] = { } status_src[16] = {
{ NULL, "No error" }, { NULL, "No error" },
{ NULL, NULL }, { NULL, NULL },
{ report_ccb_status, "CCB" }, { report_ccb_status, "CCB" },
{ report_jump_status, "Jump" }, { report_jump_status, "Jump" },
{ report_deco_status, "DECO" }, { report_deco_status, "DECO" },
{ NULL, NULL }, { NULL, "Queue Manager Interface" },
{ report_jr_status, "Job Ring" }, { report_jr_status, "Job Ring" },
{ report_cond_code_status, "Condition Code" }, { report_cond_code_status, "Condition Code" },
{ NULL, NULL },
{ NULL, NULL },
{ NULL, NULL },
{ NULL, NULL },
{ NULL, NULL },
{ NULL, NULL },
{ NULL, NULL },
{ NULL, NULL },
}; };
u32 ssrc = status >> JRSTA_SSRC_SHIFT; u32 ssrc = status >> JRSTA_SSRC_SHIFT;
const char *error = status_src[ssrc].error; const char *error = status_src[ssrc].error;
/* /*
* If there is no further error handling function, just * If there is an error handling function, call it to report the error.
* print the error code, error string and exit. Otherwise * Otherwise print the error source name.
* call the handler function.
*/ */
if (!status_src[ssrc].report_ssed) if (status_src[ssrc].report_ssed)
dev_err(jrdev, "%08x: %s: \n", status, status_src[ssrc].error);
else
status_src[ssrc].report_ssed(jrdev, status, error); 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 source\n", ssrc);
} }
EXPORT_SYMBOL(caam_jr_strstatus); EXPORT_SYMBOL(caam_jr_strstatus);
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment