]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
crypto: n2 - Set err to EINVAL if snprintf fails for hmac
authorHerbert Xu <herbert@gondor.apana.org.au>
Tue, 10 Sep 2024 09:30:24 +0000 (17:30 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 4 Oct 2024 14:32:30 +0000 (16:32 +0200)
[ Upstream commit ce212d2afca47acd366a2e74c76fe82c31f785ab ]

Return EINVAL if the snprintf check fails when constructing the
algorithm names.

Fixes: 8c20982caca4 ("crypto: n2 - Silence gcc format-truncation false positive warnings")
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Closes: https://lore.kernel.org/r/202409090726.TP0WfY7p-lkp@intel.com/
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/crypto/n2_core.c

index 59d472cb11e7501b294b95503a0e8c49f2bfcd13..509aeffdedc69c9dfd997120d69af0b8306f9cfa 100644 (file)
@@ -1357,6 +1357,7 @@ static int __n2_register_one_hmac(struct n2_ahash_alg *n2ahash)
        ahash->setkey = n2_hmac_async_setkey;
 
        base = &ahash->halg.base;
+       err = -EINVAL;
        if (snprintf(base->cra_name, CRYPTO_MAX_ALG_NAME, "hmac(%s)",
                     p->child_alg) >= CRYPTO_MAX_ALG_NAME)
                goto out_free_p;