]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
MLK-9710-8 tcrypt: change memory allocation for test_ahash_speed output buffer
authorVictoria Milhoan <vicki.milhoan@freescale.com>
Wed, 5 Nov 2014 12:13:05 +0000 (05:13 -0700)
committerNitin Garg <nitin.garg@freescale.com>
Fri, 16 Jan 2015 03:19:54 +0000 (21:19 -0600)
Change allocation of the tcrypt module's test_ahash_speed() output buffer to
use kmalloc().  This avoids a segmentation fault when the buffer is used in a
dma_map_*() call.

Signed-off-by: Victoria Milhoan <vicki.milhoan@freescale.com>
(cherry picked from commit 3c8c56d1bd82433af6a565d183bdb632fd01a13a)

crypto/tcrypt.c

index 0d9003ae8c61402e027ab4b5bfc933442478b966..94d2a3b59881ac91d7d22b6ee0b81996bd5eb783 100644 (file)
@@ -917,7 +917,8 @@ static void test_ahash_speed(const char *algo, unsigned int sec,
        struct tcrypt_result tresult;
        struct ahash_request *req;
        struct crypto_ahash *tfm;
-       static char output[1024];
+       const int output_size = 1024;
+       char *output = kmalloc(output_size, GFP_KERNEL);
        int i, ret;
 
        printk(KERN_INFO "\ntesting speed of async %s\n", algo);
@@ -929,9 +930,9 @@ static void test_ahash_speed(const char *algo, unsigned int sec,
                return;
        }
 
-       if (crypto_ahash_digestsize(tfm) > sizeof(output)) {
+       if (crypto_ahash_digestsize(tfm) > output_size) {
                pr_err("digestsize(%u) > outputbuffer(%zu)\n",
-                      crypto_ahash_digestsize(tfm), sizeof(output));
+                      crypto_ahash_digestsize(tfm), output_size);
                goto out;
        }