drivers/of/unittest.c:1195 of_unittest_reg() error: uninitialized symbol 'addr'.

From: Dan Carpenter
Date: Sun Feb 02 2025 - 11:37:28 EST


tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: a86bf2283d2c9769205407e2b54777c03d012939
commit: 7b937cc243e5b1df8780a0aa743ce800df6c68d1 of: Create of_root if no dtb provided by firmware
config: sparc64-randconfig-r073-20250202 (https://download.01.org/0day-ci/archive/20250202/202502022102.D4ESrh5e-lkp@xxxxxxxxx/config)
compiler: sparc64-linux-gcc (GCC) 14.2.0

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@xxxxxxxxx>
| Reported-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx>
| Closes: https://lore.kernel.org/r/202502022102.D4ESrh5e-lkp@xxxxxxxxx/

New smatch warnings:
drivers/of/unittest.c:1195 of_unittest_reg() error: uninitialized symbol 'addr'.

vim +/addr +1195 drivers/of/unittest.c

ff61bacd77f258 Rob Herring 2023-03-28 1180 static void __init of_unittest_reg(void)
ff61bacd77f258 Rob Herring 2023-03-28 1181 {
ff61bacd77f258 Rob Herring 2023-03-28 1182 struct device_node *np;
ff61bacd77f258 Rob Herring 2023-03-28 1183 int ret;
ff61bacd77f258 Rob Herring 2023-03-28 1184 u64 addr, size;
ff61bacd77f258 Rob Herring 2023-03-28 1185
ff61bacd77f258 Rob Herring 2023-03-28 1186 np = of_find_node_by_path("/testcase-data/address-tests/bus@80000000/device@1000");
ff61bacd77f258 Rob Herring 2023-03-28 1187 if (!np) {
ff61bacd77f258 Rob Herring 2023-03-28 1188 pr_err("missing testcase data\n");
ff61bacd77f258 Rob Herring 2023-03-28 1189 return;
ff61bacd77f258 Rob Herring 2023-03-28 1190 }
ff61bacd77f258 Rob Herring 2023-03-28 1191
ff61bacd77f258 Rob Herring 2023-03-28 1192 ret = of_property_read_reg(np, 0, &addr, &size);
ff61bacd77f258 Rob Herring 2023-03-28 1193 unittest(!ret, "of_property_read_reg(%pOF) returned error %d\n",
ff61bacd77f258 Rob Herring 2023-03-28 1194 np, ret);

unittest() just prints pass/fail.

ff61bacd77f258 Rob Herring 2023-03-28 @1195 unittest(addr == 0x1000, "of_property_read_reg(%pOF) untranslated address (%llx) incorrect\n",
^^^^^^^^^^^^^^
uninitialized but harmless

ff61bacd77f258 Rob Herring 2023-03-28 1196 np, addr);
ff61bacd77f258 Rob Herring 2023-03-28 1197
ff61bacd77f258 Rob Herring 2023-03-28 1198 of_node_put(np);
ff61bacd77f258 Rob Herring 2023-03-28 1199 }

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