[PATCH v2 08/14] iommu/mediatek-v1: fix device leak on probe_device()

Johan Hovold posted 14 patches 4 months, 1 week ago
There is a newer version of this series
[PATCH v2 08/14] iommu/mediatek-v1: fix device leak on probe_device()
Posted by Johan Hovold 4 months, 1 week ago
Make sure to drop the reference taken to the iommu platform device when
looking up its driver data during probe_device().

Fixes: b17336c55d89 ("iommu/mediatek: add support for mtk iommu generation one HW")
Cc: stable@vger.kernel.org	# 4.8
Cc: Honghui Zhang <honghui.zhang@mediatek.com>
Acked-by: Robin Murphy <robin.murphy@arm.com>
Signed-off-by: Johan Hovold <johan@kernel.org>
---
 drivers/iommu/mtk_iommu_v1.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/iommu/mtk_iommu_v1.c b/drivers/iommu/mtk_iommu_v1.c
index 10cc0b1197e8..de9153c0a82f 100644
--- a/drivers/iommu/mtk_iommu_v1.c
+++ b/drivers/iommu/mtk_iommu_v1.c
@@ -435,6 +435,8 @@ static int mtk_iommu_v1_create_mapping(struct device *dev,
 			return -EINVAL;
 
 		dev_iommu_priv_set(dev, platform_get_drvdata(m4updev));
+
+		put_device(&m4updev->dev);
 	}
 
 	ret = iommu_fwspec_add_ids(dev, args->args, 1);
-- 
2.49.1
Re: [PATCH v2 08/14] iommu/mediatek-v1: fix device leak on probe_device()
Posted by Yong Wu (吴勇) 3 months, 3 weeks ago
On Tue, 2025-10-07 at 11:43 +0200, Johan Hovold wrote:
> External email : Please do not click links or open attachments until
> you have verified the sender or the content.
> 
> 
> Make sure to drop the reference taken to the iommu platform device
> when
> looking up its driver data during probe_device().
> 
> Fixes: b17336c55d89 ("iommu/mediatek: add support for mtk iommu
> generation one HW")
> Cc: stable@vger.kernel.org      # 4.8
> Cc: Honghui Zhang <honghui.zhang@mediatek.com>
> Acked-by: Robin Murphy <robin.murphy@arm.com>
> Signed-off-by: Johan Hovold <johan@kernel.org>

Reviewed-by: Yong Wu <yong.wu@mediatek.com>