2022-04-21 06:43:10

by Dan Carpenter

[permalink] [raw]
Subject: sound/soc/sh/rcar/ssiu.c:112 rsnd_ssiu_busif_err_status_clear() error: uninitialized symbol 'offset'.

tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: b2d229d4ddb17db541098b83524d901257e93845
commit: cfb7b8bf1e2d660583dd91d870cec2f6728cbdbc ASoC: rsnd: tidyup rsnd_ssiu_busif_err_status_clear()
config: h8300-randconfig-m031-20220418 (https://download.01.org/0day-ci/archive/20220420/[email protected]/config)
compiler: h8300-linux-gcc (GCC) 11.2.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <[email protected]>
Reported-by: Dan Carpenter <[email protected]>

smatch warnings:
sound/soc/sh/rcar/ssiu.c:112 rsnd_ssiu_busif_err_status_clear() error: uninitialized symbol 'offset'.
sound/soc/sh/rcar/ssiu.c:114 rsnd_ssiu_busif_err_status_clear() error: uninitialized symbol 'shift'.

vim +/offset +112 sound/soc/sh/rcar/ssiu.c

83b220cf8eb2aa Kuninori Morimoto 2021-05-27 89 bool rsnd_ssiu_busif_err_status_clear(struct rsnd_mod *mod)
83b220cf8eb2aa Kuninori Morimoto 2021-05-27 90 {
83b220cf8eb2aa Kuninori Morimoto 2021-05-27 91 bool error = false;
83b220cf8eb2aa Kuninori Morimoto 2021-05-27 92 int id = rsnd_mod_id(mod);
cfb7b8bf1e2d66 Kuninori Morimoto 2021-05-27 93 int shift, offset;
83b220cf8eb2aa Kuninori Morimoto 2021-05-27 94 int i;
83b220cf8eb2aa Kuninori Morimoto 2021-05-27 95
83b220cf8eb2aa Kuninori Morimoto 2021-05-27 96 switch (id) {
83b220cf8eb2aa Kuninori Morimoto 2021-05-27 97 case 0:
83b220cf8eb2aa Kuninori Morimoto 2021-05-27 98 case 1:
83b220cf8eb2aa Kuninori Morimoto 2021-05-27 99 case 2:
83b220cf8eb2aa Kuninori Morimoto 2021-05-27 100 case 3:
83b220cf8eb2aa Kuninori Morimoto 2021-05-27 101 case 4:
cfb7b8bf1e2d66 Kuninori Morimoto 2021-05-27 102 shift = id;
cfb7b8bf1e2d66 Kuninori Morimoto 2021-05-27 103 offset = 0;
83b220cf8eb2aa Kuninori Morimoto 2021-05-27 104 break;
83b220cf8eb2aa Kuninori Morimoto 2021-05-27 105 case 9:
cfb7b8bf1e2d66 Kuninori Morimoto 2021-05-27 106 shift = 1;
cfb7b8bf1e2d66 Kuninori Morimoto 2021-05-27 107 offset = 1;
cfb7b8bf1e2d66 Kuninori Morimoto 2021-05-27 108 break;

No default case. The kbuild bot does not build with the cross function
DB, but even if it did, this code is too complicated. For example,
the rsnd_ssi_probe() function calls rsnd_node_fixed_index() but does not
check for errors so Smatch thinks "id" can be equal to -EINVAL.

cfb7b8bf1e2d66 Kuninori Morimoto 2021-05-27 109 }
cfb7b8bf1e2d66 Kuninori Morimoto 2021-05-27 110
83b220cf8eb2aa Kuninori Morimoto 2021-05-27 111 for (i = 0; i < 4; i++) {
cfb7b8bf1e2d66 Kuninori Morimoto 2021-05-27 @112 u32 reg = SSI_SYS_STATUS(i * 2) + offset;
cfb7b8bf1e2d66 Kuninori Morimoto 2021-05-27 113 u32 status = rsnd_mod_read(mod, reg);
cfb7b8bf1e2d66 Kuninori Morimoto 2021-05-27 @114 u32 val = 0xf << (shift * 4);
83b220cf8eb2aa Kuninori Morimoto 2021-05-27 115
cfb7b8bf1e2d66 Kuninori Morimoto 2021-05-27 116 status &= val;
83b220cf8eb2aa Kuninori Morimoto 2021-05-27 117 if (status) {
cfb7b8bf1e2d66 Kuninori Morimoto 2021-05-27 118 struct rsnd_priv *priv = rsnd_mod_to_priv(mod);
cfb7b8bf1e2d66 Kuninori Morimoto 2021-05-27 119 struct device *dev = rsnd_priv_to_dev(priv);
cfb7b8bf1e2d66 Kuninori Morimoto 2021-05-27 120
83b220cf8eb2aa Kuninori Morimoto 2021-05-27 121 rsnd_print_irq_status(dev, "%s err status : 0x%08x\n",
83b220cf8eb2aa Kuninori Morimoto 2021-05-27 122 rsnd_mod_name(mod), status);
83b220cf8eb2aa Kuninori Morimoto 2021-05-27 123 error = true;
83b220cf8eb2aa Kuninori Morimoto 2021-05-27 124 }
cfb7b8bf1e2d66 Kuninori Morimoto 2021-05-27 125 rsnd_mod_write(mod, reg, val);
83b220cf8eb2aa Kuninori Morimoto 2021-05-27 126 }
83b220cf8eb2aa Kuninori Morimoto 2021-05-27 127
83b220cf8eb2aa Kuninori Morimoto 2021-05-27 128 return error;
83b220cf8eb2aa Kuninori Morimoto 2021-05-27 129 }

--
0-DAY CI Kernel Test Service
https://01.org/lkp