drivers/gpu/drm/i915/i915_hwmon.c:69 hwm_in_read() error: uninitialized symbol 'reg_value'.

From: Dan Carpenter
Date: Thu Feb 16 2023 - 05:55:10 EST


tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 033c40a89f55525139fd5b6342281b09b97d05bf
commit: f8572bb675250ee527d9ba35fa1ce17480407399 drm/i915/hwmon: Add HWMON current voltage support
config: x86_64-randconfig-m001-20230213 (https://download.01.org/0day-ci/archive/20230216/202302161256.eeoRFhSo-lkp@xxxxxxxxx/config)
compiler: gcc-11 (Debian 11.3.0-8) 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 <error27@xxxxxxxxx>
| Link: https://lore.kernel.org/r/202302161256.eeoRFhSo-lkp@xxxxxxxxx/

smatch warnings:
drivers/gpu/drm/i915/i915_hwmon.c:69 hwm_in_read() error: uninitialized symbol 'reg_value'.

vim +/reg_value +69 drivers/gpu/drm/i915/i915_hwmon.c

f8572bb675250e Riana Tauro 2022-10-13 57 static int
f8572bb675250e Riana Tauro 2022-10-13 58 hwm_in_read(struct hwm_drvdata *ddat, u32 attr, long *val)
f8572bb675250e Riana Tauro 2022-10-13 59 {
f8572bb675250e Riana Tauro 2022-10-13 60 struct i915_hwmon *hwmon = ddat->hwmon;
f8572bb675250e Riana Tauro 2022-10-13 61 intel_wakeref_t wakeref;
f8572bb675250e Riana Tauro 2022-10-13 62 u32 reg_value;
f8572bb675250e Riana Tauro 2022-10-13 63
f8572bb675250e Riana Tauro 2022-10-13 64 switch (attr) {
f8572bb675250e Riana Tauro 2022-10-13 65 case hwmon_in_input:
f8572bb675250e Riana Tauro 2022-10-13 66 with_intel_runtime_pm(ddat->uncore->rpm, wakeref)
f8572bb675250e Riana Tauro 2022-10-13 67 reg_value = intel_uncore_read(ddat->uncore, hwmon->rg.gt_perf_status);

The with_intel_runtime_pm() macro is a complicated if statement, but
written as a for loop so it can do a get() and a put()? reg_value is
not initialized in the without pm case.

f8572bb675250e Riana Tauro 2022-10-13 68 /* HW register value in units of 2.5 millivolt */
f8572bb675250e Riana Tauro 2022-10-13 @69 *val = DIV_ROUND_CLOSEST(REG_FIELD_GET(GEN12_VOLTAGE_MASK, reg_value) * 25, 10);
f8572bb675250e Riana Tauro 2022-10-13 70 return 0;
f8572bb675250e Riana Tauro 2022-10-13 71 default:
f8572bb675250e Riana Tauro 2022-10-13 72 return -EOPNOTSUPP;
f8572bb675250e Riana Tauro 2022-10-13 73 }
f8572bb675250e Riana Tauro 2022-10-13 74 }

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