]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
crypto: virtio - Drop superfluous [as]kcipher_req pointer
authorLukas Wunner <lukas@wunner.de>
Mon, 3 Feb 2025 13:37:05 +0000 (14:37 +0100)
committerHerbert Xu <herbert@gondor.apana.org.au>
Sat, 22 Feb 2025 07:56:02 +0000 (15:56 +0800)
The request context virtio_crypto_{akcipher,sym}_request contains a
pointer to the [as]kcipher_request itself.

The pointer is superfluous as it can be calculated with container_of().

Drop the superfluous pointer.

Signed-off-by: Lukas Wunner <lukas@wunner.de>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
drivers/crypto/virtio/virtio_crypto_akcipher_algs.c
drivers/crypto/virtio/virtio_crypto_skcipher_algs.c

index ac8eb3d07c93908fec9dbc85796154f036e8cfe4..2e44915c9f2390fef25c837f7db3cb87d0ab33b3 100644 (file)
@@ -35,7 +35,6 @@ struct virtio_crypto_akcipher_ctx {
 
 struct virtio_crypto_akcipher_request {
        struct virtio_crypto_request base;
-       struct akcipher_request *akcipher_req;
        void *src_buf;
        void *dst_buf;
        uint32_t opcode;
@@ -67,7 +66,9 @@ static void virtio_crypto_dataq_akcipher_callback(struct virtio_crypto_request *
 {
        struct virtio_crypto_akcipher_request *vc_akcipher_req =
                container_of(vc_req, struct virtio_crypto_akcipher_request, base);
-       struct akcipher_request *akcipher_req;
+       struct akcipher_request *akcipher_req =
+               container_of((void *)vc_akcipher_req, struct akcipher_request,
+                            __ctx);
        int error;
 
        switch (vc_req->status) {
@@ -86,8 +87,7 @@ static void virtio_crypto_dataq_akcipher_callback(struct virtio_crypto_request *
                break;
        }
 
-       akcipher_req = vc_akcipher_req->akcipher_req;
-       /* actual length maybe less than dst buffer */
+       /* actual length may be less than dst buffer */
        akcipher_req->dst_len = len - sizeof(vc_req->status);
        sg_copy_from_buffer(akcipher_req->dst, sg_nents(akcipher_req->dst),
                            vc_akcipher_req->dst_buf, akcipher_req->dst_len);
@@ -319,7 +319,6 @@ static int virtio_crypto_rsa_req(struct akcipher_request *req, uint32_t opcode)
 
        vc_req->dataq = data_vq;
        vc_req->alg_cb = virtio_crypto_dataq_akcipher_callback;
-       vc_akcipher_req->akcipher_req = req;
        vc_akcipher_req->opcode = opcode;
 
        return crypto_transfer_akcipher_request_to_engine(data_vq->engine, req);
index e2a481a29b7774721b66517c9c827b0e2217996e..1b3fb21a2a7de290f811e9051f687c8f1a11b8a7 100644 (file)
@@ -27,7 +27,6 @@ struct virtio_crypto_sym_request {
 
        /* Cipher or aead */
        uint32_t type;
-       struct skcipher_request *skcipher_req;
        uint8_t *iv;
        /* Encryption? */
        bool encrypt;
@@ -55,7 +54,9 @@ static void virtio_crypto_dataq_sym_callback
 {
        struct virtio_crypto_sym_request *vc_sym_req =
                container_of(vc_req, struct virtio_crypto_sym_request, base);
-       struct skcipher_request *ablk_req;
+       struct skcipher_request *ablk_req =
+               container_of((void *)vc_sym_req, struct skcipher_request,
+                            __ctx);
        int error;
 
        /* Finish the encrypt or decrypt process */
@@ -75,7 +76,6 @@ static void virtio_crypto_dataq_sym_callback
                        error = -EIO;
                        break;
                }
-               ablk_req = vc_sym_req->skcipher_req;
                virtio_crypto_skcipher_finalize_req(vc_sym_req,
                                                        ablk_req, error);
        }
@@ -479,7 +479,6 @@ static int virtio_crypto_skcipher_encrypt(struct skcipher_request *req)
 
        vc_req->dataq = data_vq;
        vc_req->alg_cb = virtio_crypto_dataq_sym_callback;
-       vc_sym_req->skcipher_req = req;
        vc_sym_req->encrypt = true;
 
        return crypto_transfer_skcipher_request_to_engine(data_vq->engine, req);
@@ -503,7 +502,6 @@ static int virtio_crypto_skcipher_decrypt(struct skcipher_request *req)
 
        vc_req->dataq = data_vq;
        vc_req->alg_cb = virtio_crypto_dataq_sym_callback;
-       vc_sym_req->skcipher_req = req;
        vc_sym_req->encrypt = false;
 
        return crypto_transfer_skcipher_request_to_engine(data_vq->engine, req);