]> Gentwo Git Trees - linux/.git/commitdiff
iommu/tegra: fix device leak on probe_device()
authorJohan Hovold <johan@kernel.org>
Mon, 20 Oct 2025 04:53:18 +0000 (06:53 +0200)
committerJoerg Roedel <joerg.roedel@amd.com>
Mon, 17 Nov 2025 08:49:45 +0000 (09:49 +0100)
Make sure to drop the reference taken to the iommu platform device when
looking up its driver data during probe_device().

Note that commit 9826e393e4a8 ("iommu/tegra-smmu: Fix missing
put_device() call in tegra_smmu_find") fixed the leak in an error path,
but the reference is still leaking on success.

Fixes: 891846516317 ("memory: Add NVIDIA Tegra memory controller support")
Cc: stable@vger.kernel.org # 3.19: 9826e393e4a8
Cc: Miaoqian Lin <linmq006@gmail.com>
Acked-by: Robin Murphy <robin.murphy@arm.com>
Acked-by: Thierry Reding <treding@nvidia.com>
Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
drivers/iommu/tegra-smmu.c

index 336e0a3ff41fb129792b9f1a739bc24cc9aad55c..c391e7f2cde6960ad76abe3c787049666cf71a23 100644 (file)
@@ -830,10 +830,9 @@ static struct tegra_smmu *tegra_smmu_find(struct device_node *np)
                return NULL;
 
        mc = platform_get_drvdata(pdev);
-       if (!mc) {
-               put_device(&pdev->dev);
+       put_device(&pdev->dev);
+       if (!mc)
                return NULL;
-       }
 
        return mc->smmu;
 }