crypto: testmgr - use kmemdup instead of kmalloc+memcpy
Subsystems (2)
PATCH 1/1 crypto: testmgr - use kmemdup instead of kmalloc+memcpy
From: Eric Biggers <[email protected]>
It's recommended to use kmemdup instead of kmalloc followed by memcpy.
Signed-off-by Eric Biggers <[email protected]>
--- crypto/testmgr.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
crypto/testmgr.c +2 -4
@@ -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);
Signature · 1 line
2.11.0
Herbert Xu
maintainerQuoted 5 lines · Eric Biggers
From: Eric Biggers <[email protected]>
It's recommended to use kmemdup instead of kmalloc followed by memcpy.
Signed-off-by Eric Biggers <[email protected]>
Patch applied. Thanks.
Signature · 3 lines
Email: Herbert Xu <[email protected]> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt