diff options
author | Eric Biggers <ebiggers@google.com> | 2016-12-30 15:12:00 -0500 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2017-01-12 11:24:37 -0500 |
commit | d2110224a66779fc2c833d2c16caa73e2e23591e (patch) | |
tree | 71d4acef30e32953db70b68e68cb004be08a6fb9 /crypto/testmgr.c | |
parent | 4cf0662888026d5c1b62ed3fa8dc048a2ff2e124 (diff) |
crypto: testmgr - use kmemdup instead of kmalloc+memcpy
It's recommended to use kmemdup instead of kmalloc followed by memcpy.
Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'crypto/testmgr.c')
-rw-r--r-- | crypto/testmgr.c | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/crypto/testmgr.c b/crypto/testmgr.c index 44e888b0b041..881176ebd8a8 100644 --- a/crypto/testmgr.c +++ b/crypto/testmgr.c | |||
@@ -1463,13 +1463,12 @@ static int test_acomp(struct crypto_acomp *tfm, struct comp_testvec *ctemplate, | |||
1463 | int ilen = ctemplate[i].inlen; | 1463 | int ilen = ctemplate[i].inlen; |
1464 | void *input_vec; | 1464 | void *input_vec; |
1465 | 1465 | ||
1466 | input_vec = kmalloc(ilen, GFP_KERNEL); | 1466 | input_vec = kmemdup(ctemplate[i].input, ilen, GFP_KERNEL); |
1467 | if (!input_vec) { | 1467 | if (!input_vec) { |
1468 | ret = -ENOMEM; | 1468 | ret = -ENOMEM; |
1469 | goto out; | 1469 | goto out; |
1470 | } | 1470 | } |
1471 | 1471 | ||
1472 | memcpy(input_vec, ctemplate[i].input, ilen); | ||
1473 | memset(output, 0, dlen); | 1472 | memset(output, 0, dlen); |
1474 | init_completion(&result.completion); | 1473 | init_completion(&result.completion); |
1475 | sg_init_one(&src, input_vec, ilen); | 1474 | sg_init_one(&src, input_vec, ilen); |
@@ -1525,13 +1524,12 @@ static int test_acomp(struct crypto_acomp *tfm, struct comp_testvec *ctemplate, | |||
1525 | int ilen = dtemplate[i].inlen; | 1524 | int ilen = dtemplate[i].inlen; |
1526 | void *input_vec; | 1525 | void *input_vec; |
1527 | 1526 | ||
1528 | input_vec = kmalloc(ilen, GFP_KERNEL); | 1527 | input_vec = kmemdup(dtemplate[i].input, ilen, GFP_KERNEL); |
1529 | if (!input_vec) { | 1528 | if (!input_vec) { |
1530 | ret = -ENOMEM; | 1529 | ret = -ENOMEM; |
1531 | goto out; | 1530 | goto out; |
1532 | } | 1531 | } |
1533 | 1532 | ||
1534 | memcpy(input_vec, dtemplate[i].input, ilen); | ||
1535 | memset(output, 0, dlen); | 1533 | memset(output, 0, dlen); |
1536 | init_completion(&result.completion); | 1534 | init_completion(&result.completion); |
1537 | sg_init_one(&src, input_vec, ilen); | 1535 | sg_init_one(&src, input_vec, ilen); |