From: Dan Carpenter <error27@gmail.com>
To: oe-kbuild@lists.linux.dev, Neal Liu <neal_liu@aspeedtech.com>
Cc: lkp@intel.com, oe-kbuild-all@lists.linux.dev,
linux-kernel@vger.kernel.org,
Herbert Xu <herbert@gondor.apana.org.au>
Subject: drivers/crypto/aspeed/aspeed-acry.c:295 aspeed_acry_rsa_ctx_copy() error: uninitialized symbol 'idx'.
Date: Mon, 27 Feb 2023 07:31:07 +0300 [thread overview]
Message-ID: <202302261052.CVFRyq6F-lkp@intel.com> (raw)
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@intel.com>
| Reported-by: Dan Carpenter <error27@gmail.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
reply other threads:[~2023-02-27 4:31 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=202302261052.CVFRyq6F-lkp@intel.com \
--to=error27@gmail.com \
--cc=herbert@gondor.apana.org.au \
--cc=linux-kernel@vger.kernel.org \
--cc=lkp@intel.com \
--cc=neal_liu@aspeedtech.com \
--cc=oe-kbuild-all@lists.linux.dev \
--cc=oe-kbuild@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®