Re: sound/soc/amd/yc/pci-acp6x.c:251 snd_acp6x_probe() error: uninitialized symbol 'index'.

From: Mukunda,Vijendar
Date: Tue Nov 16 2021 - 01:55:30 EST


On 11/15/21 4:28 PM, Dan Carpenter wrote:
> Hi Vijendar,
>
> First bad commit (maybe != root cause):
>
> tree: https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgit.kernel.org%2Fpub%2Fscm%2Flinux%2Fkernel%2Fgit%2Ftorvalds%2Flinux.git&data=04%7C01%7CVijendar.Mukunda%40amd.com%7C7888a2ea4fa44a3fd1b408d9a826e7c9%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637725707327235801%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=dk4pUdo741olPkRbPf4DtZHsO1U6ppgI%2FVo%2FTb5yKVU%3D&reserved=0 master
> head: 66f4beaa6c1d28161f534471484b2daa2de1dce0
> commit: 89728d97db3f078aceb967ebe5ed2d0797b6a117 ASoC: amd: enable Yellow carp acp6x drivers build
> config: x86_64-randconfig-m001-20211028 (attached as .config)
> compiler: gcc-9 (Debian 9.3.0-22) 9.3.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:
> sound/soc/amd/yc/pci-acp6x.c:251 snd_acp6x_probe() error: uninitialized symbol 'index'.
>
> vim +/index +251 sound/soc/amd/yc/pci-acp6x.c
>
> c62442bd5d9f86 Vijendar Mukunda 2021-10-18 144 static int snd_acp6x_probe(struct pci_dev *pci,
> c62442bd5d9f86 Vijendar Mukunda 2021-10-18 145 const struct pci_device_id *pci_id)
> c62442bd5d9f86 Vijendar Mukunda 2021-10-18 146 {
> c62442bd5d9f86 Vijendar Mukunda 2021-10-18 147 struct acp6x_dev_data *adata;
> fc329c1de49825 Vijendar Mukunda 2021-10-18 148 struct platform_device_info pdevinfo[ACP6x_DEVS];
> fc329c1de49825 Vijendar Mukunda 2021-10-18 149 int ret, index;
> fc329c1de49825 Vijendar Mukunda 2021-10-18 150 int val = 0x00;
> c62442bd5d9f86 Vijendar Mukunda 2021-10-18 151 u32 addr;
> cc0deaa2dc7300 Vijendar Mukunda 2021-10-18 152 unsigned int irqflags;
> c62442bd5d9f86 Vijendar Mukunda 2021-10-18 153
> cc0deaa2dc7300 Vijendar Mukunda 2021-10-18 154 irqflags = IRQF_SHARED;
> c62442bd5d9f86 Vijendar Mukunda 2021-10-18 155 /* Yellow Carp device check */
> c62442bd5d9f86 Vijendar Mukunda 2021-10-18 156 if (pci->revision != 0x60)
> c62442bd5d9f86 Vijendar Mukunda 2021-10-18 157 return -ENODEV;
> c62442bd5d9f86 Vijendar Mukunda 2021-10-18 158
> c62442bd5d9f86 Vijendar Mukunda 2021-10-18 159 if (pci_enable_device(pci)) {
> c62442bd5d9f86 Vijendar Mukunda 2021-10-18 160 dev_err(&pci->dev, "pci_enable_device failed\n");
> c62442bd5d9f86 Vijendar Mukunda 2021-10-18 161 return -ENODEV;
> c62442bd5d9f86 Vijendar Mukunda 2021-10-18 162 }
> c62442bd5d9f86 Vijendar Mukunda 2021-10-18 163
> c62442bd5d9f86 Vijendar Mukunda 2021-10-18 164 ret = pci_request_regions(pci, "AMD ACP3x audio");
> c62442bd5d9f86 Vijendar Mukunda 2021-10-18 165 if (ret < 0) {
> c62442bd5d9f86 Vijendar Mukunda 2021-10-18 166 dev_err(&pci->dev, "pci_request_regions failed\n");
> c62442bd5d9f86 Vijendar Mukunda 2021-10-18 167 goto disable_pci;
> c62442bd5d9f86 Vijendar Mukunda 2021-10-18 168 }
> c62442bd5d9f86 Vijendar Mukunda 2021-10-18 169
> c62442bd5d9f86 Vijendar Mukunda 2021-10-18 170 adata = devm_kzalloc(&pci->dev, sizeof(struct acp6x_dev_data),
> c62442bd5d9f86 Vijendar Mukunda 2021-10-18 171 GFP_KERNEL);
> c62442bd5d9f86 Vijendar Mukunda 2021-10-18 172 if (!adata) {
> c62442bd5d9f86 Vijendar Mukunda 2021-10-18 173 ret = -ENOMEM;
> c62442bd5d9f86 Vijendar Mukunda 2021-10-18 174 goto release_regions;
> c62442bd5d9f86 Vijendar Mukunda 2021-10-18 175 }
> c62442bd5d9f86 Vijendar Mukunda 2021-10-18 176
> c62442bd5d9f86 Vijendar Mukunda 2021-10-18 177 addr = pci_resource_start(pci, 0);
> c62442bd5d9f86 Vijendar Mukunda 2021-10-18 178 adata->acp6x_base = devm_ioremap(&pci->dev, addr,
> c62442bd5d9f86 Vijendar Mukunda 2021-10-18 179 pci_resource_len(pci, 0));
> c62442bd5d9f86 Vijendar Mukunda 2021-10-18 180 if (!adata->acp6x_base) {
> c62442bd5d9f86 Vijendar Mukunda 2021-10-18 181 ret = -ENOMEM;
> c62442bd5d9f86 Vijendar Mukunda 2021-10-18 182 goto release_regions;
> c62442bd5d9f86 Vijendar Mukunda 2021-10-18 183 }
> c62442bd5d9f86 Vijendar Mukunda 2021-10-18 184 pci_set_master(pci);
> c62442bd5d9f86 Vijendar Mukunda 2021-10-18 185 pci_set_drvdata(pci, adata);
> 8c7161f2c97b2d Vijendar Mukunda 2021-10-18 186 ret = acp6x_init(adata->acp6x_base);
> 8c7161f2c97b2d Vijendar Mukunda 2021-10-18 187 if (ret)
> 8c7161f2c97b2d Vijendar Mukunda 2021-10-18 188 goto release_regions;
> fc329c1de49825 Vijendar Mukunda 2021-10-18 189 val = acp6x_readl(adata->acp6x_base + ACP_PIN_CONFIG);
> fc329c1de49825 Vijendar Mukunda 2021-10-18 190 switch (val) {
> fc329c1de49825 Vijendar Mukunda 2021-10-18 191 case ACP_CONFIG_0:
> fc329c1de49825 Vijendar Mukunda 2021-10-18 192 case ACP_CONFIG_1:
> fc329c1de49825 Vijendar Mukunda 2021-10-18 193 case ACP_CONFIG_2:
> fc329c1de49825 Vijendar Mukunda 2021-10-18 194 case ACP_CONFIG_3:
> fc329c1de49825 Vijendar Mukunda 2021-10-18 195 case ACP_CONFIG_9:
> fc329c1de49825 Vijendar Mukunda 2021-10-18 196 case ACP_CONFIG_15:
> fc329c1de49825 Vijendar Mukunda 2021-10-18 197 dev_info(&pci->dev, "Audio Mode %d\n", val);
> fc329c1de49825 Vijendar Mukunda 2021-10-18 198 break;
>
> "index" is not set for these cases.
>
> fc329c1de49825 Vijendar Mukunda 2021-10-18 199 default:
> fc329c1de49825 Vijendar Mukunda 2021-10-18 200 adata->res = devm_kzalloc(&pci->dev,
> fc329c1de49825 Vijendar Mukunda 2021-10-18 201 sizeof(struct resource),
> fc329c1de49825 Vijendar Mukunda 2021-10-18 202 GFP_KERNEL);
> fc329c1de49825 Vijendar Mukunda 2021-10-18 203 if (!adata->res) {
> fc329c1de49825 Vijendar Mukunda 2021-10-18 204 ret = -ENOMEM;
> fc329c1de49825 Vijendar Mukunda 2021-10-18 205 goto de_init;
> fc329c1de49825 Vijendar Mukunda 2021-10-18 206 }
> fc329c1de49825 Vijendar Mukunda 2021-10-18 207
> fc329c1de49825 Vijendar Mukunda 2021-10-18 208 adata->res->name = "acp_iomem";
> fc329c1de49825 Vijendar Mukunda 2021-10-18 209 adata->res->flags = IORESOURCE_MEM;
> fc329c1de49825 Vijendar Mukunda 2021-10-18 210 adata->res->start = addr;
> fc329c1de49825 Vijendar Mukunda 2021-10-18 211 adata->res->end = addr + (ACP6x_REG_END - ACP6x_REG_START);
> fc329c1de49825 Vijendar Mukunda 2021-10-18 212
> fc329c1de49825 Vijendar Mukunda 2021-10-18 213 adata->acp6x_audio_mode = ACP6x_PDM_MODE;
> fc329c1de49825 Vijendar Mukunda 2021-10-18 214
> fc329c1de49825 Vijendar Mukunda 2021-10-18 215 memset(&pdevinfo, 0, sizeof(pdevinfo));
> fc329c1de49825 Vijendar Mukunda 2021-10-18 216 pdevinfo[0].name = "acp_yc_pdm_dma";
> fc329c1de49825 Vijendar Mukunda 2021-10-18 217 pdevinfo[0].id = 0;
> fc329c1de49825 Vijendar Mukunda 2021-10-18 218 pdevinfo[0].parent = &pci->dev;
> fc329c1de49825 Vijendar Mukunda 2021-10-18 219 pdevinfo[0].num_res = 1;
> fc329c1de49825 Vijendar Mukunda 2021-10-18 220 pdevinfo[0].res = adata->res;
> 8c7161f2c97b2d Vijendar Mukunda 2021-10-18 221
> fc329c1de49825 Vijendar Mukunda 2021-10-18 222 pdevinfo[1].name = "dmic-codec";
> fc329c1de49825 Vijendar Mukunda 2021-10-18 223 pdevinfo[1].id = 0;
> fc329c1de49825 Vijendar Mukunda 2021-10-18 224 pdevinfo[1].parent = &pci->dev;
> fc329c1de49825 Vijendar Mukunda 2021-10-18 225
> fc329c1de49825 Vijendar Mukunda 2021-10-18 226 for (index = 0; index < ACP6x_DEVS; index++) {
> fc329c1de49825 Vijendar Mukunda 2021-10-18 227 adata->pdev[index] =
> fc329c1de49825 Vijendar Mukunda 2021-10-18 228 platform_device_register_full(&pdevinfo[index]);
> fc329c1de49825 Vijendar Mukunda 2021-10-18 229 if (IS_ERR(adata->pdev[index])) {
> fc329c1de49825 Vijendar Mukunda 2021-10-18 230 dev_err(&pci->dev, "cannot register %s device\n",
> fc329c1de49825 Vijendar Mukunda 2021-10-18 231 pdevinfo[index].name);
> fc329c1de49825 Vijendar Mukunda 2021-10-18 232 ret = PTR_ERR(adata->pdev[index]);
> fc329c1de49825 Vijendar Mukunda 2021-10-18 233 goto unregister_devs;
> fc329c1de49825 Vijendar Mukunda 2021-10-18 234 }
> fc329c1de49825 Vijendar Mukunda 2021-10-18 235 }
> fc329c1de49825 Vijendar Mukunda 2021-10-18 236 break;
> fc329c1de49825 Vijendar Mukunda 2021-10-18 237 }
> cc0deaa2dc7300 Vijendar Mukunda 2021-10-18 238 ret = devm_request_irq(&pci->dev, pci->irq, acp6x_irq_handler,
> cc0deaa2dc7300 Vijendar Mukunda 2021-10-18 239 irqflags, "ACP_PCI_IRQ", adata);
> cc0deaa2dc7300 Vijendar Mukunda 2021-10-18 240 if (ret) {
> cc0deaa2dc7300 Vijendar Mukunda 2021-10-18 241 dev_err(&pci->dev, "ACP PCI IRQ request failed\n");
> cc0deaa2dc7300 Vijendar Mukunda 2021-10-18 242 goto unregister_devs;
> cc0deaa2dc7300 Vijendar Mukunda 2021-10-18 243 }
> c8212df7bc0f2e Vijendar Mukunda 2021-10-18 244 pm_runtime_set_autosuspend_delay(&pci->dev, ACP_SUSPEND_DELAY_MS);
> c8212df7bc0f2e Vijendar Mukunda 2021-10-18 245 pm_runtime_use_autosuspend(&pci->dev);
> c8212df7bc0f2e Vijendar Mukunda 2021-10-18 246 pm_runtime_put_noidle(&pci->dev);
> c8212df7bc0f2e Vijendar Mukunda 2021-10-18 247 pm_runtime_allow(&pci->dev);
> c8212df7bc0f2e Vijendar Mukunda 2021-10-18 248
> c62442bd5d9f86 Vijendar Mukunda 2021-10-18 249 return 0;
> fc329c1de49825 Vijendar Mukunda 2021-10-18 250 unregister_devs:
> fc329c1de49825 Vijendar Mukunda 2021-10-18 @251 for (--index; index >= 0; index--)
>
> Uninitialized variable "index".
>
Will fix it and post the patch.

-
Vijendar

> fc329c1de49825 Vijendar Mukunda 2021-10-18 252 platform_device_unregister(adata->pdev[index]);
> fc329c1de49825 Vijendar Mukunda 2021-10-18 253 de_init:
> fc329c1de49825 Vijendar Mukunda 2021-10-18 254 if (acp6x_deinit(adata->acp6x_base))
> fc329c1de49825 Vijendar Mukunda 2021-10-18 255 dev_err(&pci->dev, "ACP de-init failed\n");
> c62442bd5d9f86 Vijendar Mukunda 2021-10-18 256 release_regions:
> c62442bd5d9f86 Vijendar Mukunda 2021-10-18 257 pci_release_regions(pci);
> c62442bd5d9f86 Vijendar Mukunda 2021-10-18 258 disable_pci:
> c62442bd5d9f86 Vijendar Mukunda 2021-10-18 259 pci_disable_device(pci);
> c62442bd5d9f86 Vijendar Mukunda 2021-10-18 260
> c62442bd5d9f86 Vijendar Mukunda 2021-10-18 261 return ret;
> c62442bd5d9f86 Vijendar Mukunda 2021-10-18 262 }
>
> ---
> 0-DAY CI Kernel Test Service, Intel Corporation
> https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.01.org%2Fhyperkitty%2Flist%2Fkbuild-all%40lists.01.org&amp;data=04%7C01%7CVijendar.Mukunda%40amd.com%7C7888a2ea4fa44a3fd1b408d9a826e7c9%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637725707327235801%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&amp;sdata=gGdJTfvecE%2F8KukmrIY4sAlQdiOQvnF2tk35P0iixh0%3D&amp;reserved=0
>