[3.8.y.z extended stable] Patch "crypto: caam - add allocation failure handling in SPRINTFCAT macro" has been added to staging queue

Kamal Mostafa kamal at canonical.com
Mon Jun 23 21:17:28 UTC 2014


This is a note to let you know that I have just added a patch titled

    crypto: caam - add allocation failure handling in SPRINTFCAT macro

to the linux-3.8.y-queue branch of the 3.8.y.z extended stable tree 
which can be found at:

 http://kernel.ubuntu.com/git?p=ubuntu/linux.git;a=shortlog;h=refs/heads/linux-3.8.y-queue

This patch is scheduled to be released in version 3.8.13.25.

If you, or anyone else, feels it should not be added to this tree, please 
reply to this email.

For more information about the 3.8.y.z tree, see
https://wiki.ubuntu.com/Kernel/Dev/ExtendedStable

Thanks.
-Kamal

------

>From 06bfacb28a5255f387bddebd34bb687f91eeee14 Mon Sep 17 00:00:00 2001
From: Horia Geanta <horia.geanta at freescale.com>
Date: Fri, 18 Apr 2014 13:01:42 +0300
Subject: [PATCH 03/66] 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 at freescale.com>
Signed-off-by: Horia Geanta <horia.geanta at freescale.com>
Signed-off-by: Herbert Xu <herbert at gondor.apana.org.au>
Signed-off-by: Kamal Mostafa <kamal at canonical.com>
---
 drivers/crypto/caam/error.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/crypto/caam/error.c b/drivers/crypto/caam/error.c
index 30b8f74..a28c522 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)
--
1.9.1





More information about the kernel-team mailing list