Skip to content

Commit 0682e02

Browse files
horiaggregkh
authored andcommitted
crypto: caam/qi - fix error path in xts setkey
commit ad876a1 upstream. xts setkey callback returns 0 on some error paths. Fix this by returning -EINVAL. Cc: <stable@vger.kernel.org> # 4.12+ Fixes: b189817 ("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>
1 parent ccb3894 commit 0682e02

1 file changed

Lines changed: 2 additions & 4 deletions

File tree

drivers/crypto/caam/caamalg_qi.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -350,10 +350,8 @@ static int xts_ablkcipher_setkey(struct crypto_ablkcipher *ablkcipher,
350350
int ret = 0;
351351

352352
if (keylen != 2 * AES_MIN_KEY_SIZE && keylen != 2 * AES_MAX_KEY_SIZE) {
353-
crypto_ablkcipher_set_flags(ablkcipher,
354-
CRYPTO_TFM_RES_BAD_KEY_LEN);
355353
dev_err(jrdev, "key size mismatch\n");
356-
return -EINVAL;
354+
goto badkey;
357355
}
358356

359357
memcpy(ctx->key, key, keylen);
@@ -388,7 +386,7 @@ static int xts_ablkcipher_setkey(struct crypto_ablkcipher *ablkcipher,
388386
return ret;
389387
badkey:
390388
crypto_ablkcipher_set_flags(ablkcipher, CRYPTO_TFM_RES_BAD_KEY_LEN);
391-
return 0;
389+
return -EINVAL;
392390
}
393391

394392
/*

0 commit comments

Comments
 (0)