Commit 49783d0f54219e1c68eac738fdd3244b7a6cbda7

Authored by Cristian Stoica
Committed by Herbert Xu
1 parent 7222d1a341

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: Cristian Stoica <cristian.stoica@freescale.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

Showing 1 changed file with 17 additions and 8 deletions Side-by-side Diff

drivers/crypto/caam/error.c
... ... @@ -213,28 +213,37 @@
213 213 void (*report_ssed)(struct device *jrdev, const u32 status,
214 214 const char *error);
215 215 const char *error;
216   - } status_src[] = {
  216 + } status_src[16] = {
217 217 { NULL, "No error" },
218 218 { NULL, NULL },
219 219 { report_ccb_status, "CCB" },
220 220 { report_jump_status, "Jump" },
221 221 { report_deco_status, "DECO" },
222   - { NULL, NULL },
  222 + { NULL, "Queue Manager Interface" },
223 223 { report_jr_status, "Job Ring" },
224 224 { report_cond_code_status, "Condition Code" },
  225 + { NULL, NULL },
  226 + { NULL, NULL },
  227 + { NULL, NULL },
  228 + { NULL, NULL },
  229 + { NULL, NULL },
  230 + { NULL, NULL },
  231 + { NULL, NULL },
  232 + { NULL, NULL },
225 233 };
226 234 u32 ssrc = status >> JRSTA_SSRC_SHIFT;
227 235 const char *error = status_src[ssrc].error;
228 236  
229 237 /*
230   - * If there is no further error handling function, just
231   - * print the error code, error string and exit. Otherwise
232   - * call the handler function.
  238 + * If there is an error handling function, call it to report the error.
  239 + * Otherwise print the error source name.
233 240 */
234   - if (!status_src[ssrc].report_ssed)
235   - dev_err(jrdev, "%08x: %s: \n", status, status_src[ssrc].error);
236   - else
  241 + if (status_src[ssrc].report_ssed)
237 242 status_src[ssrc].report_ssed(jrdev, status, error);
  243 + else if (error)
  244 + dev_err(jrdev, "%d: %s\n", ssrc, error);
  245 + else
  246 + dev_err(jrdev, "%d: unknown error source\n", ssrc);
238 247 }
239 248 EXPORT_SYMBOL(caam_jr_strstatus);