PING: [PATCH v2] virtio-crypto: fix memory-leak

From: Lei He
Date: Wed Aug 24 2022 - 04:38:19 EST


On 2022/8/16 下午5:43, Lei He wrote:
From: lei he <helei.sig11@xxxxxxxxxxxxx>

Fix memory-leak for virtio-crypto akcipher request, this problem is
introduced by 59ca6c93387d3(virtio-crypto: implement RSA algorithm).
The leak can be reproduced and tested with the following script
inside virtual machine:

Signed-off-by: lei he <helei.sig11@xxxxxxxxxxxxx>
Acked-by: Michael S. Tsirkin <mst@xxxxxxxxxx>
Reviewed-by: Gonglei <arei.gonglei@xxxxxxxxxx>
---
drivers/crypto/virtio/virtio_crypto_akcipher_algs.c | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/drivers/crypto/virtio/virtio_crypto_akcipher_algs.c b/drivers/crypto/virtio/virtio_crypto_akcipher_algs.c
index 2a60d0525cde..168195672e2e 100644
--- a/drivers/crypto/virtio/virtio_crypto_akcipher_algs.c
+++ b/drivers/crypto/virtio/virtio_crypto_akcipher_algs.c
@@ -56,6 +56,10 @@ static void virtio_crypto_akcipher_finalize_req(
struct virtio_crypto_akcipher_request *vc_akcipher_req,
struct akcipher_request *req, int err)
{
+ kfree(vc_akcipher_req->src_buf);
+ kfree(vc_akcipher_req->dst_buf);
+ vc_akcipher_req->src_buf = NULL;
+ vc_akcipher_req->dst_buf = NULL;
virtcrypto_clear_request(&vc_akcipher_req->base);
crypto_finalize_akcipher_request(vc_akcipher_req->base.dataq->engine, req, err);

base-commit: 568035b01cfb107af8d2e4bd2fb9aea22cf5b868

PING.

Best regards,
Lei He
--
helei.sig11@xxxxxxxxxxxxx