Skip to contentSkip to conversation

iommu/omap: Fix missing put_device() call in omap_iommu_probe_device

PATCH RESEND New Miaoqian Lin 1 participant 1 message Jun 2, 2022 IOMMU

lore
Share & tools
lore
#0 lore raw

PATCH RESEND v2 1/1 iommu/omap: Fix missing put_device() call in omap_iommu_probe_device

The reference taken by 'of_find_device_by_node()' must be released when not needed anymore.
Add the corresponding 'put_device()' in the error handling path and the regular path.

Fixes ede1c2e7d4dc ("iommu/omap: Store iommu_dev pointer in arch_data")

---
changes in v2:
- move put_device() before of_node_put().
- add put_device() in the regular path.

v1 Link: https://lore.kernel.org/r/[email protected]
v2 Link: https://lore.kernel.org/r/[email protected]

---
 drivers/iommu/omap-iommu.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/iommu/omap-iommu.c +2 -0
index d9cf2820c02e..58f3efdac3f7 100644
@@ -1683,6 +1683,7 @@ static struct iommu_device *omap_iommu_probe_device(struct device *dev)
 
 		oiommu = platform_get_drvdata(pdev);
 		if (!oiommu) {
+			put_device(&pdev->dev);
 			of_node_put(np);
 			kfree(arch_data);
 			return ERR_PTR(-EINVAL);
@@ -1691,6 +1692,7 @@ static struct iommu_device *omap_iommu_probe_device(struct device *dev)
 		tmp->iommu_dev = oiommu;
 		tmp->dev = &pdev->dev;
 
+		put_device(&pdev->dev);
 		of_node_put(np);
 	}
 
Signature · 6 lines
2.25.1

_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu