Message ID | 20220816094336.27806-1-helei.sig11@bytedance.com |
---|---|
State | Superseded |
Headers | show |
Series | [v2] virtio-crypto: fix memory-leak | expand |
On 2022/8/24 下午4:38, Lei He wrote: > On 2022/8/16 下午5:43, Lei He wrote: >> From: lei he <helei.sig11@bytedance.com> >> >> 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: PING Best regards, Lei He -- helei.sig11@bytedance.com
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);