Skip to content

Commit

Permalink
crypto: caam - add allocation failure handling in SPRINTFCAT macro
Browse files Browse the repository at this point in the history
GFP_ATOMIC memory allocation could fail.
In this case, avoid NULL pointer dereference and notify user.

Cc: <[email protected]> # 3.2+
Cc: Kim Phillips <[email protected]>
Signed-off-by: Horia Geanta <[email protected]>
Signed-off-by: Herbert Xu <[email protected]>
  • Loading branch information
horiag authored and herbertx committed Apr 28, 2014
1 parent eb4a534 commit 27c5fb7
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions drivers/crypto/caam/error.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 27c5fb7

Please sign in to comment.