[<prev] [next>] [day] [month] [year] [list]
Message-ID: <202302261052.CVFRyq6F-lkp@intel.com>
Date: Mon, 27 Feb 2023 07:31:07 +0300
From: Dan Carpenter <error27@...il.com>
To: oe-kbuild@...ts.linux.dev, Neal Liu <neal_liu@...eedtech.com>
Cc: lkp@...el.com, oe-kbuild-all@...ts.linux.dev,
linux-kernel@...r.kernel.org,
Herbert Xu <herbert@...dor.apana.org.au>
Subject: drivers/crypto/aspeed/aspeed-acry.c:295 aspeed_acry_rsa_ctx_copy()
error: uninitialized symbol 'idx'.
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 1ec35eadc3b448c91a6b763371a7073444e95f9d
commit: 2f1cf4e50c956f882c9fc209c7cded832b67b8a3 crypto: aspeed - Add ACRY RSA driver
config: m68k-randconfig-m031-20230226 (https://download.01.org/0day-ci/archive/20230226/202302261052.CVFRyq6F-lkp@intel.com/config)
compiler: m68k-linux-gcc (GCC) 12.1.0
If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@...el.com>
| Reported-by: Dan Carpenter <error27@...il.com>
| Link: https://lore.kernel.org/r/202302261052.CVFRyq6F-lkp@intel.com/
smatch warnings:
drivers/crypto/aspeed/aspeed-acry.c:295 aspeed_acry_rsa_ctx_copy() error: uninitialized symbol 'idx'.
vim +/idx +295 drivers/crypto/aspeed/aspeed-acry.c
2f1cf4e50c956f Neal Liu 2023-01-04 250 static int aspeed_acry_rsa_ctx_copy(struct aspeed_acry_dev *acry_dev, void *buf,
2f1cf4e50c956f Neal Liu 2023-01-04 251 const void *xbuf, size_t nbytes,
2f1cf4e50c956f Neal Liu 2023-01-04 252 enum aspeed_rsa_key_mode mode)
2f1cf4e50c956f Neal Liu 2023-01-04 253 {
2f1cf4e50c956f Neal Liu 2023-01-04 254 const u8 *src = xbuf;
2f1cf4e50c956f Neal Liu 2023-01-04 255 u32 *dw_buf = (u32 *)buf;
2f1cf4e50c956f Neal Liu 2023-01-04 256 int nbits, ndw;
2f1cf4e50c956f Neal Liu 2023-01-04 257 int i, j, idx;
2f1cf4e50c956f Neal Liu 2023-01-04 258 u32 data = 0;
2f1cf4e50c956f Neal Liu 2023-01-04 259
2f1cf4e50c956f Neal Liu 2023-01-04 260 ACRY_DBG(acry_dev, "nbytes:%zu, mode:%d\n", nbytes, mode);
2f1cf4e50c956f Neal Liu 2023-01-04 261
2f1cf4e50c956f Neal Liu 2023-01-04 262 if (nbytes > ASPEED_ACRY_RSA_MAX_KEY_LEN)
2f1cf4e50c956f Neal Liu 2023-01-04 263 return -ENOMEM;
2f1cf4e50c956f Neal Liu 2023-01-04 264
2f1cf4e50c956f Neal Liu 2023-01-04 265 /* Remove the leading zeros */
2f1cf4e50c956f Neal Liu 2023-01-04 266 while (nbytes > 0 && src[0] == 0) {
2f1cf4e50c956f Neal Liu 2023-01-04 267 src++;
2f1cf4e50c956f Neal Liu 2023-01-04 268 nbytes--;
2f1cf4e50c956f Neal Liu 2023-01-04 269 }
2f1cf4e50c956f Neal Liu 2023-01-04 270
2f1cf4e50c956f Neal Liu 2023-01-04 271 nbits = nbytes * 8;
2f1cf4e50c956f Neal Liu 2023-01-04 272 if (nbytes > 0)
2f1cf4e50c956f Neal Liu 2023-01-04 273 nbits -= count_leading_zeros(src[0]) - (BITS_PER_LONG - 8);
2f1cf4e50c956f Neal Liu 2023-01-04 274
2f1cf4e50c956f Neal Liu 2023-01-04 275 /* double-world alignment */
2f1cf4e50c956f Neal Liu 2023-01-04 276 ndw = DIV_ROUND_UP(nbytes, BYTES_PER_DWORD);
2f1cf4e50c956f Neal Liu 2023-01-04 277
2f1cf4e50c956f Neal Liu 2023-01-04 278 if (nbytes > 0) {
2f1cf4e50c956f Neal Liu 2023-01-04 279 i = BYTES_PER_DWORD - nbytes % BYTES_PER_DWORD;
2f1cf4e50c956f Neal Liu 2023-01-04 280 i %= BYTES_PER_DWORD;
2f1cf4e50c956f Neal Liu 2023-01-04 281
2f1cf4e50c956f Neal Liu 2023-01-04 282 for (j = ndw; j > 0; j--) {
2f1cf4e50c956f Neal Liu 2023-01-04 283 for (; i < BYTES_PER_DWORD; i++) {
2f1cf4e50c956f Neal Liu 2023-01-04 284 data <<= 8;
2f1cf4e50c956f Neal Liu 2023-01-04 285 data |= *src++;
2f1cf4e50c956f Neal Liu 2023-01-04 286 }
2f1cf4e50c956f Neal Liu 2023-01-04 287
2f1cf4e50c956f Neal Liu 2023-01-04 288 i = 0;
2f1cf4e50c956f Neal Liu 2023-01-04 289
2f1cf4e50c956f Neal Liu 2023-01-04 290 if (mode == ASPEED_RSA_EXP_MODE)
2f1cf4e50c956f Neal Liu 2023-01-04 291 idx = acry_dev->exp_dw_mapping[j - 1];
2f1cf4e50c956f Neal Liu 2023-01-04 292 else if (mode == ASPEED_RSA_MOD_MODE)
2f1cf4e50c956f Neal Liu 2023-01-04 293 idx = acry_dev->mod_dw_mapping[j - 1];
idx not initialized for if it's not EXPR and not MOD. Just do:
} else { /* mode == ASPEED_RSA_MOD_MODE */
idx = acry_dev->mod_dw_mapping[j - 1];
}
2f1cf4e50c956f Neal Liu 2023-01-04 294
2f1cf4e50c956f Neal Liu 2023-01-04 @295 dw_buf[idx] = cpu_to_le32(data);
2f1cf4e50c956f Neal Liu 2023-01-04 296 }
2f1cf4e50c956f Neal Liu 2023-01-04 297 }
2f1cf4e50c956f Neal Liu 2023-01-04 298
2f1cf4e50c956f Neal Liu 2023-01-04 299 return nbits;
2f1cf4e50c956f Neal Liu 2023-01-04 300 }
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests
Powered by blists - more mailing lists