summaryrefslogtreecommitdiffstats
path: root/crypto/rsa-pkcs1pad.c
diff options
context:
space:
mode:
authorDan Aloni <dan@kernelim.com>2018-09-17 13:24:32 -0400
committerHerbert Xu <herbert@gondor.apana.org.au>2018-09-28 00:46:06 -0400
commit3944f139d5592790b70bc64f197162e643a8512b (patch)
treed14df970cd0bc5de63b694bcb379ce65e5d5c52c /crypto/rsa-pkcs1pad.c
parentcdf640a69f44d2a728da85a9c65b4e99c56047a9 (diff)
crypto: fix a memory leak in rsa-kcs1pad's encryption mode
The encryption mode of pkcs1pad never uses out_sg and out_buf, so there's no need to allocate the buffer, which presently is not even being freed. CC: Herbert Xu <herbert@gondor.apana.org.au> CC: linux-crypto@vger.kernel.org CC: "David S. Miller" <davem@davemloft.net> Signed-off-by: Dan Aloni <dan@kernelim.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'crypto/rsa-pkcs1pad.c')
-rw-r--r--crypto/rsa-pkcs1pad.c9
1 files changed, 0 insertions, 9 deletions
diff --git a/crypto/rsa-pkcs1pad.c b/crypto/rsa-pkcs1pad.c
index 9893dbfc1af4..812476e46821 100644
--- a/crypto/rsa-pkcs1pad.c
+++ b/crypto/rsa-pkcs1pad.c
@@ -261,15 +261,6 @@ static int pkcs1pad_encrypt(struct akcipher_request *req)
261 pkcs1pad_sg_set_buf(req_ctx->in_sg, req_ctx->in_buf, 261 pkcs1pad_sg_set_buf(req_ctx->in_sg, req_ctx->in_buf,
262 ctx->key_size - 1 - req->src_len, req->src); 262 ctx->key_size - 1 - req->src_len, req->src);
263 263
264 req_ctx->out_buf = kmalloc(ctx->key_size, GFP_KERNEL);
265 if (!req_ctx->out_buf) {
266 kfree(req_ctx->in_buf);
267 return -ENOMEM;
268 }
269
270 pkcs1pad_sg_set_buf(req_ctx->out_sg, req_ctx->out_buf,
271 ctx->key_size, NULL);
272
273 akcipher_request_set_tfm(&req_ctx->child_req, ctx->child); 264 akcipher_request_set_tfm(&req_ctx->child_req, ctx->child);
274 akcipher_request_set_callback(&req_ctx->child_req, req->base.flags, 265 akcipher_request_set_callback(&req_ctx->child_req, req->base.flags,
275 pkcs1pad_encrypt_sign_complete_cb, req); 266 pkcs1pad_encrypt_sign_complete_cb, req);