]>
Commit | Line | Data |
---|---|---|
69c3e91f GKH |
1 | From ad876a18048f43b1f66f5d474b7598538668c5de Mon Sep 17 00:00:00 2001 |
2 | From: =?UTF-8?q?Horia=20Geant=C4=83?= <horia.geanta@nxp.com> | |
3 | Date: Mon, 6 Aug 2018 15:29:39 +0300 | |
4 | Subject: crypto: caam/qi - fix error path in xts setkey | |
5 | MIME-Version: 1.0 | |
6 | Content-Type: text/plain; charset=UTF-8 | |
7 | Content-Transfer-Encoding: 8bit | |
8 | ||
9 | From: Horia Geantă <horia.geanta@nxp.com> | |
10 | ||
11 | commit ad876a18048f43b1f66f5d474b7598538668c5de upstream. | |
12 | ||
13 | xts setkey callback returns 0 on some error paths. | |
14 | Fix this by returning -EINVAL. | |
15 | ||
16 | Cc: <stable@vger.kernel.org> # 4.12+ | |
17 | Fixes: b189817cf789 ("crypto: caam/qi - add ablkcipher and authenc algorithms") | |
18 | Signed-off-by: Horia Geantă <horia.geanta@nxp.com> | |
19 | Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> | |
20 | Signed-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 | /* |