]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
crypto: rsa-pkcs1pad - Use akcipher_request_complete
authorHerbert Xu <herbert@gondor.apana.org.au>
Tue, 31 Jan 2023 08:02:04 +0000 (16:02 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 11 Mar 2023 15:26:37 +0000 (16:26 +0100)
[ Upstream commit 564cabc0ca0bdfa8f0fc1ae74b24d0a7554522c5 ]

Use the akcipher_request_complete helper instead of calling the
completion function directly.  In fact the previous code was buggy
in that EINPROGRESS was never passed back to the original caller.

Fixes: 3d5b1ecdea6f ("crypto: rsa - RSA padding algorithm")
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Sasha Levin <sashal@kernel.org>
crypto/rsa-pkcs1pad.c

index 3279b457c4ede7879b2240839a8f232eb7676b60..0c70fbcd293d926ab8a5c0210806e485b4116175 100644 (file)
@@ -216,16 +216,14 @@ static void pkcs1pad_encrypt_sign_complete_cb(
                struct crypto_async_request *child_async_req, int err)
 {
        struct akcipher_request *req = child_async_req->data;
-       struct crypto_async_request async_req;
 
        if (err == -EINPROGRESS)
-               return;
+               goto out;
+
+       err = pkcs1pad_encrypt_sign_complete(req, err);
 
-       async_req.data = req->base.data;
-       async_req.tfm = crypto_akcipher_tfm(crypto_akcipher_reqtfm(req));
-       async_req.flags = child_async_req->flags;
-       req->base.complete(&async_req,
-                       pkcs1pad_encrypt_sign_complete(req, err));
+out:
+       akcipher_request_complete(req, err);
 }
 
 static int pkcs1pad_encrypt(struct akcipher_request *req)
@@ -336,15 +334,14 @@ static void pkcs1pad_decrypt_complete_cb(
                struct crypto_async_request *child_async_req, int err)
 {
        struct akcipher_request *req = child_async_req->data;
-       struct crypto_async_request async_req;
 
        if (err == -EINPROGRESS)
-               return;
+               goto out;
+
+       err = pkcs1pad_decrypt_complete(req, err);
 
-       async_req.data = req->base.data;
-       async_req.tfm = crypto_akcipher_tfm(crypto_akcipher_reqtfm(req));
-       async_req.flags = child_async_req->flags;
-       req->base.complete(&async_req, pkcs1pad_decrypt_complete(req, err));
+out:
+       akcipher_request_complete(req, err);
 }
 
 static int pkcs1pad_decrypt(struct akcipher_request *req)
@@ -506,15 +503,14 @@ static void pkcs1pad_verify_complete_cb(
                struct crypto_async_request *child_async_req, int err)
 {
        struct akcipher_request *req = child_async_req->data;
-       struct crypto_async_request async_req;
 
        if (err == -EINPROGRESS)
-               return;
+               goto out;
 
-       async_req.data = req->base.data;
-       async_req.tfm = crypto_akcipher_tfm(crypto_akcipher_reqtfm(req));
-       async_req.flags = child_async_req->flags;
-       req->base.complete(&async_req, pkcs1pad_verify_complete(req, err));
+       err = pkcs1pad_verify_complete(req, err);
+
+out:
+       akcipher_request_complete(req, err);
 }
 
 /*