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
commit 27c5fb7a84242b66bf1e0b2fe6bf40d19bcc5c04 upstream.

GFP_ATOMIC memory allocation could fail.
In this case, avoid NULL pointer dereference and notify user.

Cc: Kim Phillips <[email protected]>
Signed-off-by: Horia Geanta <[email protected]>
Signed-off-by: Herbert Xu <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
horiag authored and engine95 committed Sep 25, 2017
1 parent b1fe34f commit cf70a91
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 cf70a91

Please sign in to comment.