]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/4.14.69/crypto-caam-qi-fix-error-path-in-xts-setkey.patch
4.9-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 4.14.69 / crypto-caam-qi-fix-error-path-in-xts-setkey.patch
CommitLineData
69c3e91f
GKH
1From ad876a18048f43b1f66f5d474b7598538668c5de Mon Sep 17 00:00:00 2001
2From: =?UTF-8?q?Horia=20Geant=C4=83?= <horia.geanta@nxp.com>
3Date: Mon, 6 Aug 2018 15:29:39 +0300
4Subject: crypto: caam/qi - fix error path in xts setkey
5MIME-Version: 1.0
6Content-Type: text/plain; charset=UTF-8
7Content-Transfer-Encoding: 8bit
8
9From: Horia Geantă <horia.geanta@nxp.com>
10
11commit ad876a18048f43b1f66f5d474b7598538668c5de upstream.
12
13xts setkey callback returns 0 on some error paths.
14Fix this by returning -EINVAL.
15
16Cc: <stable@vger.kernel.org> # 4.12+
17Fixes: b189817cf789 ("crypto: caam/qi - add ablkcipher and authenc algorithms")
18Signed-off-by: Horia Geantă <horia.geanta@nxp.com>
19Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
20Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
21
22---
23 drivers/crypto/caam/caamalg_qi.c | 6 ++----
24 1 file changed, 2 insertions(+), 4 deletions(-)
25
26--- a/drivers/crypto/caam/caamalg_qi.c
27+++ b/drivers/crypto/caam/caamalg_qi.c
28@@ -350,10 +350,8 @@ static int xts_ablkcipher_setkey(struct
29 int ret = 0;
30
31 if (keylen != 2 * AES_MIN_KEY_SIZE && keylen != 2 * AES_MAX_KEY_SIZE) {
32- crypto_ablkcipher_set_flags(ablkcipher,
33- CRYPTO_TFM_RES_BAD_KEY_LEN);
34 dev_err(jrdev, "key size mismatch\n");
35- return -EINVAL;
36+ goto badkey;
37 }
38
39 memcpy(ctx->key, key, keylen);
40@@ -388,7 +386,7 @@ static int xts_ablkcipher_setkey(struct
41 return ret;
42 badkey:
43 crypto_ablkcipher_set_flags(ablkcipher, CRYPTO_TFM_RES_BAD_KEY_LEN);
44- return 0;
45+ return -EINVAL;
46 }
47
48 /*