aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/crypto
diff options
context:
space:
mode:
authorCristian Stoica <cristian.stoica@freescale.com>2014-11-05 04:21:24 -0500
committerHerbert Xu <herbert@gondor.apana.org.au>2014-11-06 10:15:05 -0500
commit49783d0f54219e1c68eac738fdd3244b7a6cbda7 (patch)
tree4b64bc6e585dce05e5f9ad15284f6b60b0d4d7dd /drivers/crypto
parent7222d1a3410388c8e21a5028ba2beb498938b57f (diff)
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>
Diffstat (limited to 'drivers/crypto')
-rw-r--r--drivers/crypto/caam/error.c25
1 files changed, 17 insertions, 8 deletions
diff --git a/drivers/crypto/caam/error.c b/drivers/crypto/caam/error.c
index 6531054a44c8..66d73bf54166 100644
--- a/drivers/crypto/caam/error.c
+++ b/drivers/crypto/caam/error.c
@@ -213,27 +213,36 @@ void caam_jr_strstatus(struct device *jrdev, u32 status)
213 void (*report_ssed)(struct device *jrdev, const u32 status, 213 void (*report_ssed)(struct device *jrdev, const u32 status,
214 const char *error); 214 const char *error);
215 const char *error; 215 const char *error;
216 } status_src[] = { 216 } status_src[16] = {
217 { NULL, "No error" }, 217 { NULL, "No error" },
218 { NULL, NULL }, 218 { NULL, NULL },
219 { report_ccb_status, "CCB" }, 219 { report_ccb_status, "CCB" },
220 { report_jump_status, "Jump" }, 220 { report_jump_status, "Jump" },
221 { report_deco_status, "DECO" }, 221 { report_deco_status, "DECO" },
222 { NULL, NULL }, 222 { NULL, "Queue Manager Interface" },
223 { report_jr_status, "Job Ring" }, 223 { report_jr_status, "Job Ring" },
224 { report_cond_code_status, "Condition Code" }, 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 u32 ssrc = status >> JRSTA_SSRC_SHIFT; 234 u32 ssrc = status >> JRSTA_SSRC_SHIFT;
227 const char *error = status_src[ssrc].error; 235 const char *error = status_src[ssrc].error;
228 236
229 /* 237 /*
230 * If there is no further error handling function, just 238 * If there is an error handling function, call it to report the error.
231 * print the error code, error string and exit. Otherwise 239 * Otherwise print the error source name.
232 * call the handler function.
233 */ 240 */
234 if (!status_src[ssrc].report_ssed) 241 if (status_src[ssrc].report_ssed)
235 dev_err(jrdev, "%08x: %s: \n", status, status_src[ssrc].error);
236 else
237 status_src[ssrc].report_ssed(jrdev, status, error); 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}
239EXPORT_SYMBOL(caam_jr_strstatus); 248EXPORT_SYMBOL(caam_jr_strstatus);