drivers/net/wireless/intel/iwlwifi/fw/pnvm.c:332 iwl_pnvm_load() error: uninitialized symbol 'len'.

From: Dan Carpenter
Date: Mon Aug 30 2021 - 06:23:28 EST


tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 64b4fc45bea6f4faa843d2f97ff51665280efee1
commit: 9dad325f9d57508b154f0bebbc341a8528e5729c iwlwifi: support loading the reduced power table from UEFI
date: 10 weeks ago
config: arc-randconfig-m031-20210827 (attached as .config)
compiler: arceb-elf-gcc (GCC) 11.2.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@xxxxxxxxx>
Reported-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx>

smatch warnings:
drivers/net/wireless/intel/iwlwifi/fw/pnvm.c:332 iwl_pnvm_load() error: uninitialized symbol 'len'.

vim +/len +332 drivers/net/wireless/intel/iwlwifi/fw/pnvm.c

cdda18fbbefafc Luca Coelho 2021-02-10 256 int iwl_pnvm_load(struct iwl_trans *trans,
cdda18fbbefafc Luca Coelho 2021-02-10 257 struct iwl_notif_wait_data *notif_wait)
cdda18fbbefafc Luca Coelho 2021-02-10 258 {
cdda18fbbefafc Luca Coelho 2021-02-10 259 u8 *data;
cdda18fbbefafc Luca Coelho 2021-02-10 260 size_t len;
84c3c9952afbf7 Luca Coelho 2021-06-21 261 struct pnvm_sku_package *package;
cdda18fbbefafc Luca Coelho 2021-02-10 262 struct iwl_notification_wait pnvm_wait;
cdda18fbbefafc Luca Coelho 2021-02-10 263 static const u16 ntf_cmds[] = { WIDE_ID(REGULATORY_AND_NVM_GROUP,
cdda18fbbefafc Luca Coelho 2021-02-10 264 PNVM_INIT_COMPLETE_NTFY) };
cdda18fbbefafc Luca Coelho 2021-02-10 265 int ret;
cdda18fbbefafc Luca Coelho 2021-02-10 266
cdda18fbbefafc Luca Coelho 2021-02-10 267 /* if the SKU_ID is empty, there's nothing to do */
cdda18fbbefafc Luca Coelho 2021-02-10 268 if (!trans->sku_id[0] && !trans->sku_id[1] && !trans->sku_id[2])
cdda18fbbefafc Luca Coelho 2021-02-10 269 return 0;
cdda18fbbefafc Luca Coelho 2021-02-10 270
cdda18fbbefafc Luca Coelho 2021-02-10 271 /*
cdda18fbbefafc Luca Coelho 2021-02-10 272 * If we already loaded (or tried to load) it before, we just
cdda18fbbefafc Luca Coelho 2021-02-10 273 * need to set it again.
cdda18fbbefafc Luca Coelho 2021-02-10 274 */
cdda18fbbefafc Luca Coelho 2021-02-10 275 if (trans->pnvm_loaded) {
cdda18fbbefafc Luca Coelho 2021-02-10 276 ret = iwl_trans_set_pnvm(trans, NULL, 0);
cdda18fbbefafc Luca Coelho 2021-02-10 277 if (ret)
cdda18fbbefafc Luca Coelho 2021-02-10 278 return ret;
cdda18fbbefafc Luca Coelho 2021-02-10 279 goto skip_parse;
^^^^^^^^^^^^^^^^
"len" not initialized here.

cdda18fbbefafc Luca Coelho 2021-02-10 280 }
cdda18fbbefafc Luca Coelho 2021-02-10 281
a1a6a4cf49eceb Luca Coelho 2021-02-11 282 /* First attempt to get the PNVM from BIOS */
84c3c9952afbf7 Luca Coelho 2021-06-21 283 package = iwl_uefi_get_pnvm(trans, &len);
84c3c9952afbf7 Luca Coelho 2021-06-21 284 if (!IS_ERR_OR_NULL(package)) {
84c3c9952afbf7 Luca Coelho 2021-06-21 285 data = kmemdup(package->data, len, GFP_KERNEL);
84c3c9952afbf7 Luca Coelho 2021-06-21 286
84c3c9952afbf7 Luca Coelho 2021-06-21 287 /* free package regardless of whether kmemdup succeeded */
84c3c9952afbf7 Luca Coelho 2021-06-21 288 kfree(package);
84c3c9952afbf7 Luca Coelho 2021-06-21 289
84c3c9952afbf7 Luca Coelho 2021-06-21 290 if (data) {
84c3c9952afbf7 Luca Coelho 2021-06-21 291 /* we need only the data size */
84c3c9952afbf7 Luca Coelho 2021-06-21 292 len -= sizeof(*package);
a1a6a4cf49eceb Luca Coelho 2021-02-11 293 goto parse;
84c3c9952afbf7 Luca Coelho 2021-06-21 294 }
84c3c9952afbf7 Luca Coelho 2021-06-21 295 }
a1a6a4cf49eceb Luca Coelho 2021-02-11 296
a1a6a4cf49eceb Luca Coelho 2021-02-11 297 /* If it's not available, try from the filesystem */
cdda18fbbefafc Luca Coelho 2021-02-10 298 ret = iwl_pnvm_get_from_fs(trans, &data, &len);
cdda18fbbefafc Luca Coelho 2021-02-10 299 if (ret) {
82a08d0cd7b503 Johannes Berg 2021-01-15 300 /*
82a08d0cd7b503 Johannes Berg 2021-01-15 301 * Pretend we've loaded it - at least we've tried and
82a08d0cd7b503 Johannes Berg 2021-01-15 302 * couldn't load it at all, so there's no point in
82a08d0cd7b503 Johannes Berg 2021-01-15 303 * trying again over and over.
82a08d0cd7b503 Johannes Berg 2021-01-15 304 */
82a08d0cd7b503 Johannes Berg 2021-01-15 305 trans->pnvm_loaded = true;
6972592850c00e Luca Coelho 2020-10-08 306
cdda18fbbefafc Luca Coelho 2021-02-10 307 goto skip_parse;
1c58bed4b7f755 Johannes Berg 2021-01-15 308 }
b3e4c0f34c1752 Luca Coelho 2020-10-08 309
a1a6a4cf49eceb Luca Coelho 2021-02-11 310 parse:
cdda18fbbefafc Luca Coelho 2021-02-10 311 iwl_pnvm_parse(trans, data, len);
cdda18fbbefafc Luca Coelho 2021-02-10 312
cdda18fbbefafc Luca Coelho 2021-02-10 313 kfree(data);
cdda18fbbefafc Luca Coelho 2021-02-10 314
cdda18fbbefafc Luca Coelho 2021-02-10 315 skip_parse:
9dad325f9d5750 Luca Coelho 2021-06-21 316 data = NULL;
9dad325f9d5750 Luca Coelho 2021-06-21 317 /* now try to get the reduce power table, if not loaded yet */
9dad325f9d5750 Luca Coelho 2021-06-21 318 if (!trans->reduce_power_loaded) {
9dad325f9d5750 Luca Coelho 2021-06-21 319 data = iwl_uefi_get_reduced_power(trans, &len);

Possibly initialized here? I looked at this and wasn't certain.

9dad325f9d5750 Luca Coelho 2021-06-21 320 if (IS_ERR_OR_NULL(data)) {
9dad325f9d5750 Luca Coelho 2021-06-21 321 /*
9dad325f9d5750 Luca Coelho 2021-06-21 322 * Pretend we've loaded it - at least we've tried and
9dad325f9d5750 Luca Coelho 2021-06-21 323 * couldn't load it at all, so there's no point in
9dad325f9d5750 Luca Coelho 2021-06-21 324 * trying again over and over.
9dad325f9d5750 Luca Coelho 2021-06-21 325 */
9dad325f9d5750 Luca Coelho 2021-06-21 326 trans->reduce_power_loaded = true;
9dad325f9d5750 Luca Coelho 2021-06-21 327
9dad325f9d5750 Luca Coelho 2021-06-21 328 goto skip_reduce_power;
9dad325f9d5750 Luca Coelho 2021-06-21 329 }
9dad325f9d5750 Luca Coelho 2021-06-21 330 }
9dad325f9d5750 Luca Coelho 2021-06-21 331
9dad325f9d5750 Luca Coelho 2021-06-21 @332 ret = iwl_trans_set_reduce_power(trans, data, len);
^^^

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@xxxxxxxxxxxx