Skip to content

Commit de2954d

Browse files
kimphillherbertx
authored andcommitted
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>
1 parent 701af31 commit de2954d

2 files changed

Lines changed: 4 additions & 3 deletions

File tree

‎drivers/crypto/caam/caamalg.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ static void split_key_done(struct device *dev, u32 *desc, u32 err,
113113
dev_err(dev, "%s %d: err 0x%x\n", __func__, __LINE__, err);
114114
#endif
115115
if (err) {
116-
char tmp[256];
116+
char tmp[CAAM_ERROR_STR_MAX];
117117

118118
dev_err(dev, "%08x: %s\n", err, caam_jr_strstatus(tmp, err));
119119
}
@@ -414,7 +414,7 @@ static void ipsec_esp_encrypt_done(struct device *jrdev, u32 *desc, u32 err,
414414
offsetof(struct ipsec_esp_edesc, hw_desc));
415415

416416
if (err) {
417-
char tmp[256];
417+
char tmp[CAAM_ERROR_STR_MAX];
418418

419419
dev_err(jrdev, "%08x: %s\n", err, caam_jr_strstatus(tmp, err));
420420
}
@@ -454,7 +454,7 @@ static void ipsec_esp_decrypt_done(struct device *jrdev, u32 *desc, u32 err,
454454
offsetof(struct ipsec_esp_edesc, hw_desc));
455455

456456
if (err) {
457-
char tmp[256];
457+
char tmp[CAAM_ERROR_STR_MAX];
458458

459459
dev_err(jrdev, "%08x: %s\n", err, caam_jr_strstatus(tmp, err));
460460
}

‎drivers/crypto/caam/error.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@
66

77
#ifndef CAAM_ERROR_H
88
#define CAAM_ERROR_H
9+
#define CAAM_ERROR_STR_MAX 302
910
extern char *caam_jr_strstatus(char *outstr, u32 status);
1011
#endif /* CAAM_ERROR_H */

0 commit comments

Comments
 (0)