mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
synced 2025-01-09 15:29:16 +00:00
crypto: testmgr - use kmemdup
Fixes coccinnelle alerts: /crypto/testmgr.c:2112:13-20: WARNING opportunity for kmemdup /crypto/testmgr.c:2130:13-20: WARNING opportunity for kmemdup /crypto/testmgr.c:2152:9-16: WARNING opportunity for kmemdup Signed-off-by: Christopher Diaz Riveros <chrisadr@gentoo.org> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
This commit is contained in:
parent
8336bdf12a
commit
e3d90e52ea
@ -2115,12 +2115,11 @@ static int do_test_kpp(struct crypto_kpp *tfm, const struct kpp_testvec *vec,
|
|||||||
|
|
||||||
if (vec->genkey) {
|
if (vec->genkey) {
|
||||||
/* Save party A's public key */
|
/* Save party A's public key */
|
||||||
a_public = kzalloc(out_len_max, GFP_KERNEL);
|
a_public = kmemdup(sg_virt(req->dst), out_len_max, GFP_KERNEL);
|
||||||
if (!a_public) {
|
if (!a_public) {
|
||||||
err = -ENOMEM;
|
err = -ENOMEM;
|
||||||
goto free_output;
|
goto free_output;
|
||||||
}
|
}
|
||||||
memcpy(a_public, sg_virt(req->dst), out_len_max);
|
|
||||||
} else {
|
} else {
|
||||||
/* Verify calculated public key */
|
/* Verify calculated public key */
|
||||||
if (memcmp(vec->expected_a_public, sg_virt(req->dst),
|
if (memcmp(vec->expected_a_public, sg_virt(req->dst),
|
||||||
@ -2133,13 +2132,12 @@ static int do_test_kpp(struct crypto_kpp *tfm, const struct kpp_testvec *vec,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Calculate shared secret key by using counter part (b) public key. */
|
/* Calculate shared secret key by using counter part (b) public key. */
|
||||||
input_buf = kzalloc(vec->b_public_size, GFP_KERNEL);
|
input_buf = kmemdup(vec->b_public, vec->b_public_size, GFP_KERNEL);
|
||||||
if (!input_buf) {
|
if (!input_buf) {
|
||||||
err = -ENOMEM;
|
err = -ENOMEM;
|
||||||
goto free_output;
|
goto free_output;
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(input_buf, vec->b_public, vec->b_public_size);
|
|
||||||
sg_init_one(&src, input_buf, vec->b_public_size);
|
sg_init_one(&src, input_buf, vec->b_public_size);
|
||||||
sg_init_one(&dst, output_buf, out_len_max);
|
sg_init_one(&dst, output_buf, out_len_max);
|
||||||
kpp_request_set_input(req, &src, vec->b_public_size);
|
kpp_request_set_input(req, &src, vec->b_public_size);
|
||||||
@ -2155,12 +2153,11 @@ static int do_test_kpp(struct crypto_kpp *tfm, const struct kpp_testvec *vec,
|
|||||||
|
|
||||||
if (vec->genkey) {
|
if (vec->genkey) {
|
||||||
/* Save the shared secret obtained by party A */
|
/* Save the shared secret obtained by party A */
|
||||||
a_ss = kzalloc(vec->expected_ss_size, GFP_KERNEL);
|
a_ss = kmemdup(sg_virt(req->dst), vec->expected_ss_size, GFP_KERNEL);
|
||||||
if (!a_ss) {
|
if (!a_ss) {
|
||||||
err = -ENOMEM;
|
err = -ENOMEM;
|
||||||
goto free_all;
|
goto free_all;
|
||||||
}
|
}
|
||||||
memcpy(a_ss, sg_virt(req->dst), vec->expected_ss_size);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Calculate party B's shared secret by using party A's
|
* Calculate party B's shared secret by using party A's
|
||||||
|
Loading…
x
Reference in New Issue
Block a user