aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHoria Geanta <horia.geanta@freescale.com>2014-04-18 13:01:42 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2014-06-07 13:25:39 -0700
commitd1ae1920b53e00849397c3f6f63dace219de46a0 (patch)
treedc32031813515547e3790bd261bda9be5c7f7e8b
parenta0d3102153fc5d9cf8bb49b62ac9655f9f63b493 (diff)
downloadlinux-linaro-stable-d1ae1920b53e00849397c3f6f63dace219de46a0.tar.gz
crypto: caam - add allocation failure handling in SPRINTFCAT macro
commit 27c5fb7a84242b66bf1e0b2fe6bf40d19bcc5c04 upstream. GFP_ATOMIC memory allocation could fail. In this case, avoid NULL pointer dereference and notify user. Cc: Kim Phillips <kim.phillips@freescale.com> Signed-off-by: Horia Geanta <horia.geanta@freescale.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/crypto/caam/error.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/drivers/crypto/caam/error.c b/drivers/crypto/caam/error.c
index 9f25f5296029..0eabd81e1a90 100644
--- a/drivers/crypto/caam/error.c
+++ b/drivers/crypto/caam/error.c
@@ -16,9 +16,13 @@
char *tmp; \
\
tmp = kmalloc(sizeof(format) + max_alloc, GFP_ATOMIC); \
- sprintf(tmp, format, param); \
- strcat(str, tmp); \
- kfree(tmp); \
+ if (likely(tmp)) { \
+ sprintf(tmp, format, param); \
+ strcat(str, tmp); \
+ kfree(tmp); \
+ } else { \
+ strcat(str, "kmalloc failure in SPRINTFCAT"); \
+ } \
}
static void report_jump_idx(u32 status, char *outstr)