aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/crypto/ccree/cc_cipher.c
diff options
context:
space:
mode:
authorGilad Ben-Yossef <gilad@benyossef.com>2019-04-18 16:38:46 +0300
committerHerbert Xu <herbert@gondor.apana.org.au>2019-04-25 15:38:14 +0800
commita108f9311c01271bccad45d321cf9ddfac852c4b (patch)
tree61f1684502035612cc7e8e52bf3acb5bdcf2c933 /drivers/crypto/ccree/cc_cipher.c
parentcrypto: ccree - add CID and PID support (diff)
downloadlinux-dev-a108f9311c01271bccad45d321cf9ddfac852c4b.tar.xz
linux-dev-a108f9311c01271bccad45d321cf9ddfac852c4b.zip
crypto: ccree - fix backlog notifications
We were doing backlog notification callbacks via a cipher/hash/aead request structure cast to the base structure, which may or may not work based on how the structure is laid in memory and is not safe. Fix it by delegating the backlog notification to the appropriate internal callbacks which are type aware. Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com> Cc: stable@vger.kernel.org # v4.19+ Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'drivers/crypto/ccree/cc_cipher.c')
-rw-r--r--drivers/crypto/ccree/cc_cipher.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/drivers/crypto/ccree/cc_cipher.c b/drivers/crypto/ccree/cc_cipher.c
index 15da3a35a6a1..1ba7c8a7bd52 100644
--- a/drivers/crypto/ccree/cc_cipher.c
+++ b/drivers/crypto/ccree/cc_cipher.c
@@ -818,9 +818,13 @@ static void cc_cipher_complete(struct device *dev, void *cc_req, int err)
struct crypto_skcipher *sk_tfm = crypto_skcipher_reqtfm(req);
unsigned int ivsize = crypto_skcipher_ivsize(sk_tfm);
- cc_unmap_cipher_request(dev, req_ctx, ivsize, src, dst);
- memcpy(req->iv, req_ctx->iv, ivsize);
- kzfree(req_ctx->iv);
+ if (err != -EINPROGRESS) {
+ /* Not a BACKLOG notification */
+ cc_unmap_cipher_request(dev, req_ctx, ivsize, src, dst);
+ memcpy(req->iv, req_ctx->iv, ivsize);
+ kzfree(req_ctx->iv);
+ }
+
skcipher_request_complete(req, err);
}