From 781e4301e0c4d7a86a198c867164c13ad727837e Mon Sep 17 00:00:00 2001 From: Winston Hudson Date: Sun, 21 Jul 2013 15:18:38 -0700 Subject: Fix for tcrypt test_ahash_speed function. This patch adds a null pointer check and explicitly frees memory in the tcrypt.c function test_ahash_speed. Signed-off-by: Winston Hudson --- crypto/tcrypt.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/crypto/tcrypt.c b/crypto/tcrypt.c index 6ff34df13b5c..2c1d3ae34161 100644 --- a/crypto/tcrypt.c +++ b/crypto/tcrypt.c @@ -662,12 +662,18 @@ static void test_ahash_speed(const char *algo, unsigned int sec, char *output = kmalloc(output_size, GFP_KERNEL); int i, ret; + if (!output) { + printk(KERN_INFO "\nUnable to allocate output buffer memory\n"); + return; + } + printk(KERN_INFO "\ntesting speed of async %s\n", algo); tfm = crypto_alloc_ahash(algo, 0, 0); if (IS_ERR(tfm)) { pr_err("failed to load transform for %s: %ld\n", algo, PTR_ERR(tfm)); + kfree(output); return; } @@ -717,6 +723,7 @@ static void test_ahash_speed(const char *algo, unsigned int sec, ahash_request_free(req); out: + kfree(output); crypto_free_ahash(tfm); } -- cgit v1.2.3