crypto: lskcipher - Return EINVAL when ecb_name fails sanity checks
authorHerbert Xu <herbert@gondor.apana.org.au>
Thu, 12 Oct 2023 05:11:25 +0000 (13:11 +0800)
committerHerbert Xu <herbert@gondor.apana.org.au>
Fri, 20 Oct 2023 05:39:26 +0000 (13:39 +0800)
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@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Closes: https://lore.kernel.org/r/202310111323.ZjK7bzjw-lkp@intel.com/
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
crypto/lskcipher.c

index 9be3c04bc62a396a42bced6064d10c8e2192b071..cb6170ebcaa36ceb1e490d0ca2814fc7ae734660 100644 (file)
@@ -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)