diff options
author | Christopher Diaz Riveros <chrisadr@gentoo.org> | 2019-01-28 19:01:18 -0500 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2019-02-08 02:29:48 -0500 |
commit | e3d90e52ea5fe58d39297df1c825db6e131fb04f (patch) | |
tree | e9f4b62f1816dcf9753a6ec1b3e5b98775c998d9 /crypto/testmgr.c | |
parent | 8336bdf12a9ea5bb77bb32d215a34485fb66245c (diff) |
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>
Diffstat (limited to 'crypto/testmgr.c')
-rw-r--r-- | crypto/testmgr.c | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/crypto/testmgr.c b/crypto/testmgr.c index 17f57f277e58..01a517e3f06b 100644 --- a/crypto/testmgr.c +++ b/crypto/testmgr.c | |||
@@ -2115,12 +2115,11 @@ static int do_test_kpp(struct crypto_kpp *tfm, const struct kpp_testvec *vec, | |||
2115 | 2115 | ||
2116 | if (vec->genkey) { | 2116 | if (vec->genkey) { |
2117 | /* Save party A's public key */ | 2117 | /* Save party A's public key */ |
2118 | a_public = kzalloc(out_len_max, GFP_KERNEL); | 2118 | a_public = kmemdup(sg_virt(req->dst), out_len_max, GFP_KERNEL); |
2119 | if (!a_public) { | 2119 | if (!a_public) { |
2120 | err = -ENOMEM; | 2120 | err = -ENOMEM; |
2121 | goto free_output; | 2121 | goto free_output; |
2122 | } | 2122 | } |
2123 | memcpy(a_public, sg_virt(req->dst), out_len_max); | ||
2124 | } else { | 2123 | } else { |
2125 | /* Verify calculated public key */ | 2124 | /* Verify calculated public key */ |
2126 | if (memcmp(vec->expected_a_public, sg_virt(req->dst), | 2125 | 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, | |||
2133 | } | 2132 | } |
2134 | 2133 | ||
2135 | /* Calculate shared secret key by using counter part (b) public key. */ | 2134 | /* Calculate shared secret key by using counter part (b) public key. */ |
2136 | input_buf = kzalloc(vec->b_public_size, GFP_KERNEL); | 2135 | input_buf = kmemdup(vec->b_public, vec->b_public_size, GFP_KERNEL); |
2137 | if (!input_buf) { | 2136 | if (!input_buf) { |
2138 | err = -ENOMEM; | 2137 | err = -ENOMEM; |
2139 | goto free_output; | 2138 | goto free_output; |
2140 | } | 2139 | } |
2141 | 2140 | ||
2142 | memcpy(input_buf, vec->b_public, vec->b_public_size); | ||
2143 | sg_init_one(&src, input_buf, vec->b_public_size); | 2141 | sg_init_one(&src, input_buf, vec->b_public_size); |
2144 | sg_init_one(&dst, output_buf, out_len_max); | 2142 | sg_init_one(&dst, output_buf, out_len_max); |
2145 | kpp_request_set_input(req, &src, vec->b_public_size); | 2143 | 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, | |||
2155 | 2153 | ||
2156 | if (vec->genkey) { | 2154 | if (vec->genkey) { |
2157 | /* Save the shared secret obtained by party A */ | 2155 | /* Save the shared secret obtained by party A */ |
2158 | a_ss = kzalloc(vec->expected_ss_size, GFP_KERNEL); | 2156 | a_ss = kmemdup(sg_virt(req->dst), vec->expected_ss_size, GFP_KERNEL); |
2159 | if (!a_ss) { | 2157 | if (!a_ss) { |
2160 | err = -ENOMEM; | 2158 | err = -ENOMEM; |
2161 | goto free_all; | 2159 | goto free_all; |
2162 | } | 2160 | } |
2163 | memcpy(a_ss, sg_virt(req->dst), vec->expected_ss_size); | ||
2164 | 2161 | ||
2165 | /* | 2162 | /* |
2166 | * Calculate party B's shared secret by using party A's | 2163 | * Calculate party B's shared secret by using party A's |