Hello Suravee Suthikulpanit,

The patch 06687a03805e: "iommu/amd: Improve error handling for
amd_iommu_init_pci" from Mar 1, 2022, leads to the following Smatch
static checker warning:

        drivers/iommu/amd/init.c:1989 amd_iommu_init_pci()
        warn: duplicate check 'ret' (previous on line 1978)

drivers/iommu/amd/init.c
    1951 static int __init amd_iommu_init_pci(void)
    1952 {
    1953         struct amd_iommu *iommu;
    1954         int ret;
    1955 
    1956         for_each_iommu(iommu) {
    1957                 ret = iommu_init_pci(iommu);
    1958                 if (ret) {
    1959                         pr_err("IOMMU%d: Failed to initialize IOMMU 
Hardware (error=%d)!\n",
    1960                                iommu->index, ret);
    1961                         goto out;
    1962                 }
    1963                 /* Need to setup range after PCI init */
    1964                 iommu_set_cwwb_range(iommu);
    1965         }
    1966 
    1967         /*
    1968          * Order is important here to make sure any unity map 
requirements are
    1969          * fulfilled. The unity mappings are created and written to 
the device
    1970          * table during the amd_iommu_init_api() call.
    1971          *
    1972          * After that we call init_device_table_dma() to make sure any
    1973          * uninitialized DTE will block DMA, and in the end we flush 
the caches
    1974          * of all IOMMUs to make sure the changes to the device table 
are
    1975          * active.
    1976          */
    1977         ret = amd_iommu_init_api();
    1978         if (ret) {

The patch moved the error handling up here

    1979                 pr_err("IOMMU: Failed to initialize IOMMU-API 
interface (error=%d)!\n",
    1980                        ret);
    1981                 goto out;
    1982         }
    1983 
    1984         init_device_table_dma();
    1985 
    1986         for_each_iommu(iommu)
    1987                 iommu_flush_all_caches(iommu);
    1988 
--> 1989         if (!ret)

Where before we just checked for errors here.  This condition is
impossible now.

    1990                 print_iommu_info();
    1991 
    1992 out:
    1993         return ret;
    1994 }

regards,
dan carpenter
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu

Reply via email to