summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHoria Geantă <horia.geanta@nxp.com>2018-08-06 15:29:39 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2018-09-09 19:56:02 +0200
commit0682e027f39dfcdef5f5d9c264491a34196f3b25 (patch)
tree5af33b3440f27bd6a91311a9561e7ffed1b981ad
parentccb38942fbe180a70b773bc1dbe47d48d9458bf3 (diff)
downloadlinux-stable-0682e027f39dfcdef5f5d9c264491a34196f3b25.tar.gz
linux-stable-0682e027f39dfcdef5f5d9c264491a34196f3b25.tar.bz2
linux-stable-0682e027f39dfcdef5f5d9c264491a34196f3b25.zip
crypto: caam/qi - fix error path in xts setkey
commit ad876a18048f43b1f66f5d474b7598538668c5de upstream. xts setkey callback returns 0 on some error paths. Fix this by returning -EINVAL. Cc: <stable@vger.kernel.org> # 4.12+ Fixes: b189817cf789 ("crypto: caam/qi - add ablkcipher and authenc algorithms") Signed-off-by: Horia Geantă <horia.geanta@nxp.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/crypto/caam/caamalg_qi.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/drivers/crypto/caam/caamalg_qi.c b/drivers/crypto/caam/caamalg_qi.c
index e7966e37a5aa..ecc6d755d3c1 100644
--- a/drivers/crypto/caam/caamalg_qi.c
+++ b/drivers/crypto/caam/caamalg_qi.c
@@ -350,10 +350,8 @@ static int xts_ablkcipher_setkey(struct crypto_ablkcipher *ablkcipher,
int ret = 0;
if (keylen != 2 * AES_MIN_KEY_SIZE && keylen != 2 * AES_MAX_KEY_SIZE) {
- crypto_ablkcipher_set_flags(ablkcipher,
- CRYPTO_TFM_RES_BAD_KEY_LEN);
dev_err(jrdev, "key size mismatch\n");
- return -EINVAL;
+ goto badkey;
}
memcpy(ctx->key, key, keylen);
@@ -388,7 +386,7 @@ static int xts_ablkcipher_setkey(struct crypto_ablkcipher *ablkcipher,
return ret;
badkey:
crypto_ablkcipher_set_flags(ablkcipher, CRYPTO_TFM_RES_BAD_KEY_LEN);
- return 0;
+ return -EINVAL;
}
/*