[PATCH] crypto: lskcipher - Return EINVAL when ecb_name fails sanity checks

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Oct 11, 2023 at 10:19:31AM +0300, Dan Carpenter wrote:
>
> smatch warnings:
> crypto/lskcipher.c:639 lskcipher_alloc_instance_simple() warn: passing zero to 'ERR_PTR'

Thanks for the report.  This patch should fix the problem:

---8<---
Set the error value to -EINVAL instead of zero when the underlying
name (within "ecb()") fails basic sanity checks.

Fixes: 8aee5d4ebd11 ("crypto: lskcipher - Add compatibility wrapper around ECB")
Reported-by: kernel test robot <lkp@xxxxxxxxx>
Reported-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx>
Closes: https://lore.kernel.org/r/202310111323.ZjK7bzjw-lkp@xxxxxxxxx/

diff --git a/crypto/lskcipher.c b/crypto/lskcipher.c
index 9be3c04bc62a..cb6170ebcaa3 100644
--- a/crypto/lskcipher.c
+++ b/crypto/lskcipher.c
@@ -583,6 +583,7 @@ struct lskcipher_instance *lskcipher_alloc_instance_simple(
 	if (ecb_name[0]) {
 		int len;
 
+		err = -EINVAL;
 		len = strscpy(ecb_name, &cipher_alg->co.base.cra_name[4],
 			      sizeof(ecb_name));
 		if (len < 2)
-- 
Email: Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt



[Index of Archives]     [Kernel]     [Gnu Classpath]     [Gnu Crypto]     [DM Crypt]     [Netfilter]     [Bugtraq]
  Powered by Linux