drivers/platform/x86/thinkpad_acpi.c:10538 dytc_profile_refresh() error: uninitialized symbol 'funcmode'.

From: Dan Carpenter
Date: Thu Jun 01 2023 - 00:23:43 EST


tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 929ed21dfdb6ee94391db51c9eedb63314ef6847
commit: 1bc5d819f0b9784043ea08570e1b21107aa35739 platform/x86: thinkpad_acpi: Fix profile modes on Intel platforms
config: i386-randconfig-m021-20230531 (https://download.01.org/0day-ci/archive/20230601/202306011202.1hbgLRD4-lkp@xxxxxxxxx/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@xxxxxxxxx>
| Reported-by: Dan Carpenter <error27@xxxxxxxxx>
| Closes: https://lore.kernel.org/r/202306011202.1hbgLRD4-lkp@xxxxxxxxx/

New smatch warnings:
drivers/platform/x86/thinkpad_acpi.c:10538 dytc_profile_refresh() error: uninitialized symbol 'funcmode'.

Old smatch warnings:
drivers/platform/x86/thinkpad_acpi.c:1193 tpacpi_new_rfkill() warn: 'atp_rfk->rfkill' is an error pointer or valid
drivers/platform/x86/thinkpad_acpi.c:2606 hotkey_inputdev_close() warn: bitwise AND condition is false here
drivers/platform/x86/thinkpad_acpi.c:3776 hotkey_notify_hotkey() warn: bitwise AND condition is false here
drivers/platform/x86/thinkpad_acpi.c:10531 dytc_profile_refresh() error: uninitialized symbol 'output'.
drivers/platform/x86/thinkpad_acpi.c:10537 dytc_profile_refresh() error: uninitialized symbol 'output'.

vim +/funcmode +10538 drivers/platform/x86/thinkpad_acpi.c

c3bfcd4c676238 Mark Pearson 2021-01-11 10515 static void dytc_profile_refresh(void)
c3bfcd4c676238 Mark Pearson 2021-01-11 10516 {
c3bfcd4c676238 Mark Pearson 2021-01-11 10517 enum platform_profile_option profile;
6229ce9c36384c Hans de Goede 2022-03-09 10518 int output, err = 0;
fde5f74ccfc771 Mark Pearson 2023-01-12 10519 int perfmode, funcmode;
c3bfcd4c676238 Mark Pearson 2021-01-11 10520
c3bfcd4c676238 Mark Pearson 2021-01-11 10521 mutex_lock(&dytc_mutex);
42504af775361c Mark Pearson 2022-06-03 10522 if (dytc_capabilities & BIT(DYTC_FC_MMC)) {
7a47f86bba748b Mark Pearson 2021-04-06 10523 if (dytc_mmc_get_available)
7a47f86bba748b Mark Pearson 2021-04-06 10524 err = dytc_command(DYTC_CMD_MMC_GET, &output);
7a47f86bba748b Mark Pearson 2021-04-06 10525 else
c3bfcd4c676238 Mark Pearson 2021-01-11 10526 err = dytc_cql_command(DYTC_CMD_GET, &output);
1bc5d819f0b978 Mark Pearson 2023-01-24 10527 funcmode = DYTC_FUNCTION_MMC;
1bc5d819f0b978 Mark Pearson 2023-01-24 10528 } else if (dytc_capabilities & BIT(DYTC_FC_PSC)) {
e1c21608e3cfc4 Mark Pearson 2022-02-25 10529 err = dytc_command(DYTC_CMD_GET, &output);
1bc5d819f0b978 Mark Pearson 2023-01-24 10530 /* Check if we are PSC mode, or have AMT enabled */
1bc5d819f0b978 Mark Pearson 2023-01-24 10531 funcmode = (output >> DYTC_GET_FUNCTION_BIT) & 0xF;
1bc5d819f0b978 Mark Pearson 2023-01-24 10532 }

funcmode not initialized on else path. err is also 0 on the else path.

c3bfcd4c676238 Mark Pearson 2021-01-11 10533 mutex_unlock(&dytc_mutex);
c3bfcd4c676238 Mark Pearson 2021-01-11 10534 if (err)
c3bfcd4c676238 Mark Pearson 2021-01-11 10535 return;
c3bfcd4c676238 Mark Pearson 2021-01-11 10536
c3bfcd4c676238 Mark Pearson 2021-01-11 10537 perfmode = (output >> DYTC_GET_MODE_BIT) & 0xF;
fde5f74ccfc771 Mark Pearson 2023-01-12 @10538 convert_dytc_to_profile(funcmode, perfmode, &profile);
c3bfcd4c676238 Mark Pearson 2021-01-11 10539 if (profile != dytc_current_profile) {
c3bfcd4c676238 Mark Pearson 2021-01-11 10540 dytc_current_profile = profile;
c3bfcd4c676238 Mark Pearson 2021-01-11 10541 platform_profile_notify();
c3bfcd4c676238 Mark Pearson 2021-01-11 10542 }
c3bfcd4c676238 Mark Pearson 2021-01-11 10543 }

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