Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

crypto: caam - fix printk recursion for long error texts

during recent descriptor development, an Invalid Sequence Command
error triggered a:

BUG: recent printk recursion!

due to insufficient memory allocated for the error text.

The Invalid Sequence Command error text is the longest.
The length of the maximum error string is computed as
the sum of:

"DECO: ": 6
"jump tgt desc idx 255: ": 23
Invalid Sequence Command text: 272
zero termination character: 1

i.e, 302 characters.

Define this maximum error string length in error.h and fix
caam_jr_strstatus callsites.

Signed-off-by: Kim Phillips <kim.phillips@freescale.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

authored by

Kim Phillips and committed by
Herbert Xu
de2954d6 701af31c

+4 -3
+3 -3
drivers/crypto/caam/caamalg.c
··· 113 113 dev_err(dev, "%s %d: err 0x%x\n", __func__, __LINE__, err); 114 114 #endif 115 115 if (err) { 116 - char tmp[256]; 116 + char tmp[CAAM_ERROR_STR_MAX]; 117 117 118 118 dev_err(dev, "%08x: %s\n", err, caam_jr_strstatus(tmp, err)); 119 119 } ··· 414 414 offsetof(struct ipsec_esp_edesc, hw_desc)); 415 415 416 416 if (err) { 417 - char tmp[256]; 417 + char tmp[CAAM_ERROR_STR_MAX]; 418 418 419 419 dev_err(jrdev, "%08x: %s\n", err, caam_jr_strstatus(tmp, err)); 420 420 } ··· 454 454 offsetof(struct ipsec_esp_edesc, hw_desc)); 455 455 456 456 if (err) { 457 - char tmp[256]; 457 + char tmp[CAAM_ERROR_STR_MAX]; 458 458 459 459 dev_err(jrdev, "%08x: %s\n", err, caam_jr_strstatus(tmp, err)); 460 460 }
+1
drivers/crypto/caam/error.h
··· 6 6 7 7 #ifndef CAAM_ERROR_H 8 8 #define CAAM_ERROR_H 9 + #define CAAM_ERROR_STR_MAX 302 9 10 extern char *caam_jr_strstatus(char *outstr, u32 status); 10 11 #endif /* CAAM_ERROR_H */