drivers/crypto/n2_core.c:1406 __n2_register_one_hmac() error: uninitialized symbol 'err'.

From: Dan Carpenter
Date: Tue Sep 10 2024 - 05:18:04 EST


tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 89f5e14d05b4852db5ecdf222dc6a13edc633658
commit: 8c20982caca4b10ca79aea8134a16ea98989ca03 crypto: n2 - Silence gcc format-truncation false positive warnings
config: sparc-randconfig-r071-20240908 (https://download.01.org/0day-ci/archive/20240909/202409090726.TP0WfY7p-lkp@xxxxxxxxx/config)
compiler: sparc64-linux-gcc (GCC) 14.1.0

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@xxxxxxxxx>
| Reported-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx>
| Closes: https://lore.kernel.org/r/202409090726.TP0WfY7p-lkp@xxxxxxxxx/

smatch warnings:
drivers/crypto/n2_core.c:1406 __n2_register_one_hmac() error: uninitialized symbol 'err'.

vim +/err +1406 drivers/crypto/n2_core.c

49cfe4db2ddc4d Greg Kroah-Hartman 2012-12-21 1366 static int __n2_register_one_hmac(struct n2_ahash_alg *n2ahash)
dc4ccfd15d4fc7 David S. Miller 2010-05-22 1367 {
dc4ccfd15d4fc7 David S. Miller 2010-05-22 1368 struct n2_hmac_alg *p = kzalloc(sizeof(*p), GFP_KERNEL);
dc4ccfd15d4fc7 David S. Miller 2010-05-22 1369 struct ahash_alg *ahash;
dc4ccfd15d4fc7 David S. Miller 2010-05-22 1370 struct crypto_alg *base;
dc4ccfd15d4fc7 David S. Miller 2010-05-22 1371 int err;
dc4ccfd15d4fc7 David S. Miller 2010-05-22 1372
dc4ccfd15d4fc7 David S. Miller 2010-05-22 1373 if (!p)
dc4ccfd15d4fc7 David S. Miller 2010-05-22 1374 return -ENOMEM;
dc4ccfd15d4fc7 David S. Miller 2010-05-22 1375
dc4ccfd15d4fc7 David S. Miller 2010-05-22 1376 p->child_alg = n2ahash->alg.halg.base.cra_name;
dc4ccfd15d4fc7 David S. Miller 2010-05-22 1377 memcpy(&p->derived, n2ahash, sizeof(struct n2_ahash_alg));
dc4ccfd15d4fc7 David S. Miller 2010-05-22 1378 INIT_LIST_HEAD(&p->derived.entry);
dc4ccfd15d4fc7 David S. Miller 2010-05-22 1379
dc4ccfd15d4fc7 David S. Miller 2010-05-22 1380 ahash = &p->derived.alg;
dc4ccfd15d4fc7 David S. Miller 2010-05-22 1381 ahash->digest = n2_hmac_async_digest;
dc4ccfd15d4fc7 David S. Miller 2010-05-22 1382 ahash->setkey = n2_hmac_async_setkey;
dc4ccfd15d4fc7 David S. Miller 2010-05-22 1383
dc4ccfd15d4fc7 David S. Miller 2010-05-22 1384 base = &ahash->halg.base;
8c20982caca4b1 Herbert Xu 2023-10-27 1385 if (snprintf(base->cra_name, CRYPTO_MAX_ALG_NAME, "hmac(%s)",
8c20982caca4b1 Herbert Xu 2023-10-27 1386 p->child_alg) >= CRYPTO_MAX_ALG_NAME)
8c20982caca4b1 Herbert Xu 2023-10-27 1387 goto out_free_p;
^^^^^^^^^^^^^^^^

8c20982caca4b1 Herbert Xu 2023-10-27 1388 if (snprintf(base->cra_driver_name, CRYPTO_MAX_ALG_NAME, "hmac-%s-n2",
8c20982caca4b1 Herbert Xu 2023-10-27 1389 p->child_alg) >= CRYPTO_MAX_ALG_NAME)
8c20982caca4b1 Herbert Xu 2023-10-27 1390 goto out_free_p;
^^^^^^^^^^^^^^^^
err = -EINVAL;

dc4ccfd15d4fc7 David S. Miller 2010-05-22 1391
dc4ccfd15d4fc7 David S. Miller 2010-05-22 1392 base->cra_ctxsize = sizeof(struct n2_hmac_ctx);
dc4ccfd15d4fc7 David S. Miller 2010-05-22 1393 base->cra_init = n2_hmac_cra_init;
dc4ccfd15d4fc7 David S. Miller 2010-05-22 1394 base->cra_exit = n2_hmac_cra_exit;
dc4ccfd15d4fc7 David S. Miller 2010-05-22 1395
dc4ccfd15d4fc7 David S. Miller 2010-05-22 1396 list_add(&p->derived.entry, &hmac_algs);
dc4ccfd15d4fc7 David S. Miller 2010-05-22 1397 err = crypto_register_ahash(ahash);
dc4ccfd15d4fc7 David S. Miller 2010-05-22 1398 if (err) {
dc4ccfd15d4fc7 David S. Miller 2010-05-22 1399 pr_err("%s alg registration failed\n", base->cra_name);
dc4ccfd15d4fc7 David S. Miller 2010-05-22 1400 list_del(&p->derived.entry);
8c20982caca4b1 Herbert Xu 2023-10-27 1401 out_free_p:
dc4ccfd15d4fc7 David S. Miller 2010-05-22 1402 kfree(p);
dc4ccfd15d4fc7 David S. Miller 2010-05-22 1403 } else {
dc4ccfd15d4fc7 David S. Miller 2010-05-22 1404 pr_info("%s alg registered\n", base->cra_name);
dc4ccfd15d4fc7 David S. Miller 2010-05-22 1405 }
dc4ccfd15d4fc7 David S. Miller 2010-05-22 @1406 return err;
dc4ccfd15d4fc7 David S. Miller 2010-05-22 1407 }

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki