]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
iommu/arm-smmu-v3: Free MSIs in case of ENOMEM
authorAleksandr Aprelkov <aaprelkov@usergate.com>
Wed, 3 Apr 2024 05:37:59 +0000 (12:37 +0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 27 Jun 2024 11:52:17 +0000 (13:52 +0200)
[ Upstream commit 80fea979dd9d48d67c5b48d2f690c5da3e543ebd ]

If devm_add_action() returns -ENOMEM, then MSIs are allocated but not
not freed on teardown. Use devm_add_action_or_reset() instead to keep
the static analyser happy.

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

Signed-off-by: Aleksandr Aprelkov <aaprelkov@usergate.com>
Link: https://lore.kernel.org/r/20240403053759.643164-1-aaprelkov@usergate.com
[will: Tweak commit message, remove warning message]
Signed-off-by: Will Deacon <will@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c

index 41f93c3ab160d0f4a6d3c47c061b23156c016aa7..3afec8714cf284f4a94599fc72211614aa50e84c 100644 (file)
@@ -3402,7 +3402,7 @@ 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);
+       devm_add_action_or_reset(dev, arm_smmu_free_msis, dev);
 }
 
 static void arm_smmu_setup_unique_irqs(struct arm_smmu_device *smmu)