From 3a01686ef6304ba830a89bf536936366e80b5aa6 Mon Sep 17 00:00:00 2001 From: Herbert Xu Date: Tue, 10 Sep 2024 17:30:24 +0800 Subject: [PATCH] crypto: n2 - Set err to EINVAL if snprintf fails for hmac BugLink: https://bugs.launchpad.net/bugs/2089340 [ 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 Reported-by: Dan Carpenter Closes: https://lore.kernel.org/r/202409090726.TP0WfY7p-lkp@intel.com/ Signed-off-by: Herbert Xu Signed-off-by: Sasha Levin Signed-off-by: Portia Stephens Signed-off-by: Stefan Bader --- drivers/crypto/n2_core.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/crypto/n2_core.c b/drivers/crypto/n2_core.c index 7a3083debc2b..996c77ea3673 100644 --- a/drivers/crypto/n2_core.c +++ b/drivers/crypto/n2_core.c @@ -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;