Skip to contentSkip to conversation

iommu/amd: Enable support for up to 2K interrupts per function

bug report Dan Carpenter 1 participant 1 message Mar 15, 2025

lore
Share & tools
lore
#0 lore raw

Hello Kishon Vijay Abraham I,

Commit 19e5cc156cbc ("iommu/amd: Enable support for up to 2K interrupts per function") from Mar 7, 2025 (linux-next), leads to the following Smatch static checker warning:

	drivers/iommu/amd/iommu.c:2401 amd_iommu_probe_device()
	error: uninitialized symbol 'dev_data'.

drivers/iommu/amd/iommu.c

    2353 static struct iommu_device *amd_iommu_probe_device(struct device *dev)
    2354 {
    2355         struct iommu_device *iommu_dev;
    2356         struct amd_iommu *iommu;
    2357         struct iommu_dev_data *dev_data;
    2358         int ret;
    2359 
    2360         if (!check_device(dev))
    2361                 return ERR_PTR(-ENODEV);
    2362 
    2363         iommu = rlookup_amd_iommu(dev);
    2364         if (!iommu)
    2365                 return ERR_PTR(-ENODEV);
    2366 
    2367         /* Not registered yet? */
    2368         if (!iommu->iommu.ops)
    2369                 return ERR_PTR(-ENODEV);
    2370 
    2371         if (dev_iommu_priv_get(dev))
    2372                 return &iommu->iommu;
    2373 
    2374         ret = iommu_init_device(iommu, dev);
    2375         if (ret) {
    2376                 dev_err(dev, "Failed to initialize - trying to proceed anyway\n");
    2377                 iommu_dev = ERR_PTR(ret);
    2378                 iommu_ignore_device(iommu, dev);
    2379                 goto out_err;

dev_data isn't initialized.

    2380         }
    2381 
    2382         amd_iommu_set_pci_msi_domain(dev, iommu);
    2383         iommu_dev = &iommu->iommu;
    2384 
    2385         /*
    2386          * If IOMMU and device supports PASID then it will contain max
    2387          * supported PASIDs, else it will be zero.
    2388          */
    2389         dev_data = dev_iommu_priv_get(dev);
    2390         if (amd_iommu_pasid_supported() && dev_is_pci(dev) &&
    2391             pdev_pasid_supported(dev_data)) {
    2392                 dev_data->max_pasids = min_t(u32, iommu->iommu.max_pasids,
    2393                                              pci_max_pasids(to_pci_dev(dev)));
    2394         }
    2395 
    2396 out_err:
    2397 
    2398         iommu_completion_wait(iommu);
    2399 
    2400         if (FEATURE_NUM_INT_REMAP_SUP_2K(amd_iommu_efr2))
--> 2401                 dev_data->max_irqs = MAX_IRQS_PER_TABLE_2K;
                         ^^^^^^^^^

    2402         else
    2403                 dev_data->max_irqs = MAX_IRQS_PER_TABLE_512;
                         ^^^^^^^^^^

Dead.

    2404 
    2405         if (dev_is_pci(dev))
    2406                 pci_prepare_ats(to_pci_dev(dev), PAGE_SHIFT);
    2407 
    2408         return iommu_dev;
    2409 }

regards,
dan carpenter