summaryrefslogtreecommitdiff
path: root/drivers/crypto
diff options
context:
space:
mode:
authorHoria Geanta <horia.geanta@freescale.com>2014-04-18 14:01:42 +0400
committerHerbert Xu <herbert@gondor.apana.org.au>2014-04-28 14:17:18 +0400
commit27c5fb7a84242b66bf1e0b2fe6bf40d19bcc5c04 (patch)
treeeece880987ed5b35e9ffbbe089d86671d188701c /drivers/crypto
parenteb4a5346e777784f1b5ae9fd0c29b96344bdc3ae (diff)
downloadlinux-27c5fb7a84242b66bf1e0b2fe6bf40d19bcc5c04.tar.xz
crypto: caam - add allocation failure handling in SPRINTFCAT macro
GFP_ATOMIC memory allocation could fail. In this case, avoid NULL pointer dereference and notify user. Cc: <stable@vger.kernel.org> # 3.2+ 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>
Diffstat (limited to 'drivers/crypto')
-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)