From: Horia Geanta Date: Fri, 18 Apr 2014 10:01:42 +0000 (+0300) Subject: crypto: caam - add allocation failure handling in SPRINTFCAT macro X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=27c5fb7a84242b66bf1e0b2fe6bf40d19bcc5c04;p=linux-beck.git 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: # 3.2+ Cc: Kim Phillips Signed-off-by: Horia Geanta Signed-off-by: Herbert Xu --- 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)