IOMMU Archive mirror
 help / color / mirror / Atom feed
From: Aleksandr Aprelkov <aaprelkov@usergate.com>
To: Will Deacon <will@kernel.org>
Cc: Aleksandr Aprelkov <aaprelkov@usergate.com>,Robin Murphy
	<robin.murphy@arm.com>,Joerg Roedel <joro@8bytes.org>,Jason
	Gunthorpe <jgg@ziepe.ca>,Nicolin Chen
	<nicolinc@nvidia.com>,Michael Shavit <mshavit@google.com>,Lu
	Baolu <baolu.lu@linux.intel.com>,Marc Zyngier
	<maz@kernel.org>,<linux-arm-kernel@lists.infradead.org>,<iommu@lists.linux.dev>,<linux-kernel@vger.kernel.org>
Subject: [PATCH] iommu/arm-smmu-v3: Free MSIs in case of ENOMEM
Date: Fri, 29 Mar 2024 16:51:33 +0700	[thread overview]
Message-ID: <20240329095133.576605-1-aaprelkov@usergate.com> (raw)

If devm_add_action() returns ENOMEM, then MSIs allocated but
not freed on teardown.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Fixes: 166bdbd23161 ("iommu/arm-smmu: Add support for MSI on SMMUv3")
Signed-off-by: Aleksandr Aprelkov <aaprelkov@usergate.com>
---
 drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
index 41f93c3ab160..136d0cdce6a9 100644
--- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
+++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
@@ -3402,7 +3402,12 @@ static void arm_smmu_setup_msis(struct arm_smmu_device *smmu)
 	smmu->priq.q.irq = msi_get_virq(dev, PRIQ_MSI_INDEX);
 
 	/* Add callback to free MSIs on teardown */
-	devm_add_action(dev, arm_smmu_free_msis, dev);
+	ret = devm_add_action(dev, arm_smmu_free_msis, dev);
+	if (ret) {
+		dev_warn(dev, "failed to add free MSIs callback - falling back to wired irqs\n");
+		arm_smmu_free_msis(dev);
+		return;
+	}
 }
 
 static void arm_smmu_setup_unique_irqs(struct arm_smmu_device *smmu)
-- 
2.34.1


             reply	other threads:[~2024-03-29  9:52 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-29  9:51 Aleksandr Aprelkov [this message]
2024-04-01 16:40 ` [PATCH] iommu/arm-smmu-v3: Free MSIs in case of ENOMEM Jonathan Cameron

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=20240329095133.576605-1-aaprelkov@usergate.com \
    --to=aaprelkov@usergate.com \
    --cc=baolu.lu@linux.intel.com \
    --cc=iommu@lists.linux.dev \
    --cc=jgg@ziepe.ca \
    --cc=joro@8bytes.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maz@kernel.org \
    --cc=mshavit@google.com \
    --cc=nicolinc@nvidia.com \
    --cc=robin.murphy@arm.com \
    --cc=will@kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).