[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20251209022258.4183415-8-maobibo@loongson.cn>
Date: Tue, 9 Dec 2025 10:22:55 +0800
From: Bibo Mao <maobibo@...ngson.cn>
To: Gonglei <arei.gonglei@...wei.com>,
"Michael S . Tsirkin" <mst@...hat.com>,
Jason Wang <jasowang@...hat.com>,
Xuan Zhuo <xuanzhuo@...ux.alibaba.com>,
Eugenio Pérez <eperezma@...hat.com>,
Herbert Xu <herbert@...dor.apana.org.au>,
"David S. Miller" <davem@...emloft.net>
Cc: kvm@...r.kernel.org,
linux-crypto@...r.kernel.org,
virtualization@...ts.linux.dev,
linux-kernel@...r.kernel.org
Subject: [PATCH v3 07/10] crypto: virtio: Add req_data with structure virtio_crypto_sym_request
With normal encrypt/decrypt workflow, req_data with struct type
virtio_crypto_op_data_req will be allocated. Here put req_data in
virtio_crypto_sym_request, it is pre-allocated when encrypt/decrypt
interface is called.
Signed-off-by: Bibo Mao <maobibo@...ngson.cn>
---
drivers/crypto/virtio/virtio_crypto_skcipher_algs.c | 13 ++++---------
1 file changed, 4 insertions(+), 9 deletions(-)
diff --git a/drivers/crypto/virtio/virtio_crypto_skcipher_algs.c b/drivers/crypto/virtio/virtio_crypto_skcipher_algs.c
index 788d2d4a9b83..bf9fdf56c2a3 100644
--- a/drivers/crypto/virtio/virtio_crypto_skcipher_algs.c
+++ b/drivers/crypto/virtio/virtio_crypto_skcipher_algs.c
@@ -26,6 +26,7 @@ struct virtio_crypto_skcipher_ctx {
struct virtio_crypto_sym_request {
struct virtio_crypto_request base;
+ struct virtio_crypto_op_data_req req_data;
/* Cipher or aead */
uint32_t type;
@@ -350,14 +351,8 @@ __virtio_crypto_skcipher_do_req(struct virtio_crypto_sym_request *vc_sym_req,
if (!sgs)
return -ENOMEM;
- req_data = kzalloc_node(sizeof(*req_data), GFP_KERNEL,
- dev_to_node(&vcrypto->vdev->dev));
- if (!req_data) {
- kfree(sgs);
- return -ENOMEM;
- }
-
- vc_req->req_data = req_data;
+ req_data = &vc_sym_req->req_data;
+ vc_req->req_data = NULL;
vc_sym_req->type = VIRTIO_CRYPTO_SYM_OP_CIPHER;
/* Head of operation */
if (vc_sym_req->encrypt) {
@@ -450,7 +445,7 @@ __virtio_crypto_skcipher_do_req(struct virtio_crypto_sym_request *vc_sym_req,
free_iv:
kfree_sensitive(iv);
free:
- kfree_sensitive(req_data);
+ memzero_explicit(req_data, sizeof(*req_data));
kfree(sgs);
return err;
}
--
2.39.3
Powered by blists - more mailing lists