mirror of https://gitee.com/openkylin/linux.git
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>
This commit is contained in:
parent
4cf0662888
commit
d2110224a6
|
@ -1463,13 +1463,12 @@ static int test_acomp(struct crypto_acomp *tfm, struct comp_testvec *ctemplate,
|
||||||
int ilen = ctemplate[i].inlen;
|
int ilen = ctemplate[i].inlen;
|
||||||
void *input_vec;
|
void *input_vec;
|
||||||
|
|
||||||
input_vec = kmalloc(ilen, GFP_KERNEL);
|
input_vec = kmemdup(ctemplate[i].input, ilen, GFP_KERNEL);
|
||||||
if (!input_vec) {
|
if (!input_vec) {
|
||||||
ret = -ENOMEM;
|
ret = -ENOMEM;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(input_vec, ctemplate[i].input, ilen);
|
|
||||||
memset(output, 0, dlen);
|
memset(output, 0, dlen);
|
||||||
init_completion(&result.completion);
|
init_completion(&result.completion);
|
||||||
sg_init_one(&src, input_vec, ilen);
|
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;
|
int ilen = dtemplate[i].inlen;
|
||||||
void *input_vec;
|
void *input_vec;
|
||||||
|
|
||||||
input_vec = kmalloc(ilen, GFP_KERNEL);
|
input_vec = kmemdup(dtemplate[i].input, ilen, GFP_KERNEL);
|
||||||
if (!input_vec) {
|
if (!input_vec) {
|
||||||
ret = -ENOMEM;
|
ret = -ENOMEM;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(input_vec, dtemplate[i].input, ilen);
|
|
||||||
memset(output, 0, dlen);
|
memset(output, 0, dlen);
|
||||||
init_completion(&result.completion);
|
init_completion(&result.completion);
|
||||||
sg_init_one(&src, input_vec, ilen);
|
sg_init_one(&src, input_vec, ilen);
|
||||||
|
|
Loading…
Reference in New Issue