diff options
Diffstat (limited to 'crypto')
-rw-r--r-- | crypto/tcrypt.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/crypto/tcrypt.c b/crypto/tcrypt.c index 2b00b617daab..46a4a757d478 100644 --- a/crypto/tcrypt.c +++ b/crypto/tcrypt.c | |||
@@ -48,6 +48,8 @@ | |||
48 | #define ENCRYPT 1 | 48 | #define ENCRYPT 1 |
49 | #define DECRYPT 0 | 49 | #define DECRYPT 0 |
50 | 50 | ||
51 | #define MAX_DIGEST_SIZE 64 | ||
52 | |||
51 | /* | 53 | /* |
52 | * return a string with the driver name | 54 | * return a string with the driver name |
53 | */ | 55 | */ |
@@ -950,7 +952,7 @@ static void test_ahash_speed(const char *algo, unsigned int secs, | |||
950 | struct tcrypt_result tresult; | 952 | struct tcrypt_result tresult; |
951 | struct ahash_request *req; | 953 | struct ahash_request *req; |
952 | struct crypto_ahash *tfm; | 954 | struct crypto_ahash *tfm; |
953 | static char output[1024]; | 955 | char *output; |
954 | int i, ret; | 956 | int i, ret; |
955 | 957 | ||
956 | tfm = crypto_alloc_ahash(algo, 0, 0); | 958 | tfm = crypto_alloc_ahash(algo, 0, 0); |
@@ -963,9 +965,9 @@ static void test_ahash_speed(const char *algo, unsigned int secs, | |||
963 | printk(KERN_INFO "\ntesting speed of async %s (%s)\n", algo, | 965 | printk(KERN_INFO "\ntesting speed of async %s (%s)\n", algo, |
964 | get_driver_name(crypto_ahash, tfm)); | 966 | get_driver_name(crypto_ahash, tfm)); |
965 | 967 | ||
966 | if (crypto_ahash_digestsize(tfm) > sizeof(output)) { | 968 | if (crypto_ahash_digestsize(tfm) > MAX_DIGEST_SIZE) { |
967 | pr_err("digestsize(%u) > outputbuffer(%zu)\n", | 969 | pr_err("digestsize(%u) > %d\n", crypto_ahash_digestsize(tfm), |
968 | crypto_ahash_digestsize(tfm), sizeof(output)); | 970 | MAX_DIGEST_SIZE); |
969 | goto out; | 971 | goto out; |
970 | } | 972 | } |
971 | 973 | ||
@@ -980,6 +982,10 @@ static void test_ahash_speed(const char *algo, unsigned int secs, | |||
980 | ahash_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG, | 982 | ahash_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG, |
981 | tcrypt_complete, &tresult); | 983 | tcrypt_complete, &tresult); |
982 | 984 | ||
985 | output = kmalloc(MAX_DIGEST_SIZE, GFP_KERNEL); | ||
986 | if (!output) | ||
987 | goto out_nomem; | ||
988 | |||
983 | for (i = 0; speed[i].blen != 0; i++) { | 989 | for (i = 0; speed[i].blen != 0; i++) { |
984 | if (speed[i].blen > TVMEMSIZE * PAGE_SIZE) { | 990 | if (speed[i].blen > TVMEMSIZE * PAGE_SIZE) { |
985 | pr_err("template (%u) too big for tvmem (%lu)\n", | 991 | pr_err("template (%u) too big for tvmem (%lu)\n", |
@@ -1006,6 +1012,9 @@ static void test_ahash_speed(const char *algo, unsigned int secs, | |||
1006 | } | 1012 | } |
1007 | } | 1013 | } |
1008 | 1014 | ||
1015 | kfree(output); | ||
1016 | |||
1017 | out_nomem: | ||
1009 | ahash_request_free(req); | 1018 | ahash_request_free(req); |
1010 | 1019 | ||
1011 | out: | 1020 | out: |