diff options
author | Eric Biggers <ebiggers@google.com> | 2016-12-30 20:12:00 (GMT) |
---|---|---|
committer | Xie Xiaobo <xiaobo.xie@nxp.com> | 2017-09-25 07:25:35 (GMT) |
commit | 2a1064d1c74e3a394f6fbbb6096c2f5e434c46e4 (patch) | |
tree | 6eb7f3ee40d927775558145071811dbb0f979301 | |
parent | f8b01a1aa1e14e47df93dff12b19677eef636c70 (diff) | |
download | linux-2a1064d1c74e3a394f6fbbb6096c2f5e434c46e4.tar.xz |
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>
-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 44e888b..881176e 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, int ilen = ctemplate[i].inlen; void *input_vec; - input_vec = kmalloc(ilen, GFP_KERNEL); + input_vec = kmemdup(ctemplate[i].input, ilen, GFP_KERNEL); if (!input_vec) { ret = -ENOMEM; goto out; } - memcpy(input_vec, ctemplate[i].input, ilen); memset(output, 0, dlen); init_completion(&result.completion); sg_init_one(&src, input_vec, ilen); @@ -1525,13 +1524,12 @@ static int test_acomp(struct crypto_acomp *tfm, struct comp_testvec *ctemplate, int ilen = dtemplate[i].inlen; void *input_vec; - input_vec = kmalloc(ilen, GFP_KERNEL); + input_vec = kmemdup(dtemplate[i].input, ilen, GFP_KERNEL); if (!input_vec) { ret = -ENOMEM; goto out; } - memcpy(input_vec, dtemplate[i].input, ilen); memset(output, 0, dlen); init_completion(&result.completion); sg_init_one(&src, input_vec, ilen); |