Re: [PATCH 02/31] crypto_pool: Add crypto_pool_reserve_scratch()
From: Dan Carpenter
Date: Mon Aug 22 2022 - 06:46:42 EST
Hi Dmitry,
url: https://github.com/intel-lab-lkp/linux/commits/Dmitry-Safonov/net-tcp-Add-TCP-AO-support/20220819-010628
base: e34cfee65ec891a319ce79797dda18083af33a76
config: x86_64-randconfig-m001 (https://download.01.org/0day-ci/archive/20220822/202208221817.t5uzfegL-lkp@xxxxxxxxx/config)
compiler: gcc-11 (Debian 11.3.0-5) 11.3.0
If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <lkp@xxxxxxxxx>
Reported-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx>
New smatch warnings:
crypto/crypto_pool.c:203 crypto_pool_alloc_ahash() error: uninitialized symbol 'err'.
vim +/err +203 crypto/crypto_pool.c
f4c3873630fc8c4 Dmitry Safonov 2022-08-18 171 int crypto_pool_alloc_ahash(const char *alg)
f4c3873630fc8c4 Dmitry Safonov 2022-08-18 172 {
f4c3873630fc8c4 Dmitry Safonov 2022-08-18 173 unsigned int i;
f4c3873630fc8c4 Dmitry Safonov 2022-08-18 174 int err;
f4c3873630fc8c4 Dmitry Safonov 2022-08-18 175
f4c3873630fc8c4 Dmitry Safonov 2022-08-18 176 /* slow-path */
f4c3873630fc8c4 Dmitry Safonov 2022-08-18 177 mutex_lock(&cpool_mutex);
f4c3873630fc8c4 Dmitry Safonov 2022-08-18 178 for (i = 0; i < last_allocated; i++) {
f4c3873630fc8c4 Dmitry Safonov 2022-08-18 179 if (cpool[i].alg && !strcmp(cpool[i].alg, alg)) {
f4c3873630fc8c4 Dmitry Safonov 2022-08-18 180 if (kref_read(&cpool[i].kref) > 0) {
f4c3873630fc8c4 Dmitry Safonov 2022-08-18 181 kref_get(&cpool[i].kref);
f4c3873630fc8c4 Dmitry Safonov 2022-08-18 182 goto out;
"err" not set. It was supposed to be set to zero at the start. But
better to say "ret = i;" here maybe?
Why is i unsigned? It leads to unsightly casts. Presumably some static
checker insists on this... :/
f4c3873630fc8c4 Dmitry Safonov 2022-08-18 183 } else {
f4c3873630fc8c4 Dmitry Safonov 2022-08-18 184 break;
f4c3873630fc8c4 Dmitry Safonov 2022-08-18 185 }
f4c3873630fc8c4 Dmitry Safonov 2022-08-18 186 }
f4c3873630fc8c4 Dmitry Safonov 2022-08-18 187 }
f4c3873630fc8c4 Dmitry Safonov 2022-08-18 188
f4c3873630fc8c4 Dmitry Safonov 2022-08-18 189 for (i = 0; i < last_allocated; i++) {
f4c3873630fc8c4 Dmitry Safonov 2022-08-18 190 if (!cpool[i].alg)
f4c3873630fc8c4 Dmitry Safonov 2022-08-18 191 break;
f4c3873630fc8c4 Dmitry Safonov 2022-08-18 192 }
f4c3873630fc8c4 Dmitry Safonov 2022-08-18 193 if (i >= CPOOL_SIZE) {
f4c3873630fc8c4 Dmitry Safonov 2022-08-18 194 err = -ENOSPC;
f4c3873630fc8c4 Dmitry Safonov 2022-08-18 195 goto out;
f4c3873630fc8c4 Dmitry Safonov 2022-08-18 196 }
f4c3873630fc8c4 Dmitry Safonov 2022-08-18 197
f4c3873630fc8c4 Dmitry Safonov 2022-08-18 198 err = __cpool_alloc_ahash(&cpool[i], alg);
f4c3873630fc8c4 Dmitry Safonov 2022-08-18 199 if (!err && last_allocated <= i)
f4c3873630fc8c4 Dmitry Safonov 2022-08-18 200 last_allocated++;
f4c3873630fc8c4 Dmitry Safonov 2022-08-18 201 out:
f4c3873630fc8c4 Dmitry Safonov 2022-08-18 202 mutex_unlock(&cpool_mutex);
f4c3873630fc8c4 Dmitry Safonov 2022-08-18 @203 return err ?: (int)i;
f4c3873630fc8c4 Dmitry Safonov 2022-08-18 204 }
--
0-DAY CI Kernel Test Service
https://01.org/lkp