All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: suravee.suthikulpanit@amd.com
Cc: iommu@lists.linux-foundation.org
Subject: [bug report] iommu/amd: Improve error handling for amd_iommu_init_pci
Date: Wed, 9 Mar 2022 10:11:22 +0300	[thread overview]
Message-ID: <20220309071122.GA24681@kili> (raw)

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
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

             reply	other threads:[~2022-03-09  7:11 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-09  7:11 Dan Carpenter [this message]
2022-03-09  8:32 ` [bug report] iommu/amd: Improve error handling for amd_iommu_init_pci Vasant Hegde via iommu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220309071122.GA24681@kili \
    --to=dan.carpenter@oracle.com \
    --cc=iommu@lists.linux-foundation.org \
    --cc=suravee.suthikulpanit@amd.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.