linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] iommu/arm-smmu-v3: Free MSIs in case of ENOMEM
@ 2024-04-03  5:37 Aleksandr Aprelkov
  2024-04-09 10:43 ` Mostafa Saleh
  2024-04-19 15:32 ` Will Deacon
  0 siblings, 2 replies; 6+ messages in thread
From: Aleksandr Aprelkov @ 2024-04-03  5:37 UTC (permalink / raw)
  To: Will Deacon
  Cc: Aleksandr Aprelkov, Robin Murphy, Joerg Roedel, Jason Gunthorpe,
	Nicolin Chen, Michael Shavit, Lu Baolu, Marc Zyngier,
	linux-arm-kernel, iommu, linux-kernel

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>
---
v2: Use appropriate function for registration failure as 
Jonathan Cameron <Jonathan.Cameron@Huawei.com> suggested.

 drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 4 +++-
 1 file changed, 3 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..8800af041e5f 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,9 @@ 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_or_reset(dev, arm_smmu_free_msis, dev);
+	if (ret)
+		dev_warn(dev, "failed to add free MSIs callback - falling back to wired irqs\n");
 }
 
 static void arm_smmu_setup_unique_irqs(struct arm_smmu_device *smmu)
-- 
2.34.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-04-19 15:33 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-03  5:37 [PATCH v2] iommu/arm-smmu-v3: Free MSIs in case of ENOMEM Aleksandr Aprelkov
2024-04-09 10:43 ` Mostafa Saleh
2024-04-09 11:17   ` Robin Murphy
2024-04-09 11:31     ` Mostafa Saleh
2024-04-09 11:46       ` Robin Murphy
2024-04-19 15:32 ` Will Deacon

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 NNTP newsgroup(s).