On Thu, Oct 02, 2025 at 01:05:08PM +0100, Robin Murphy wrote:
On 2025-09-25 1:27 pm, Johan Hovold wrote:
@@ -1663,22 +1663,22 @@ static struct iommu_device *omap_iommu_probe_device(struct device *dev) for (i = 0, tmp = arch_data; i < num_iommus; i++, tmp++) { np = of_parse_phandle(dev->of_node, "iommus", i); if (!np) {
kfree(arch_data);
return ERR_PTR(-EINVAL);
ret = -EINVAL;
}goto err_put_iommus;
pdev = of_find_device_by_node(np); if (!pdev) { of_node_put(np);
kfree(arch_data);
return ERR_PTR(-ENODEV);
ret = -ENODEV;
}goto err_put_iommus;
oiommu = platform_get_drvdata(pdev); if (!oiommu) { of_node_put(np);
kfree(arch_data);
return ERR_PTR(-EINVAL);
ret = -EINVAL;
}goto err_put_iommus;
tmp->iommu_dev = oiommu; @@ -1697,17 +1697,28 @@ static struct iommu_device *omap_iommu_probe_device(struct device *dev) oiommu = arch_data->iommu_dev; return &oiommu->iommu;
+err_put_iommus:
- for (tmp = arch_data; tmp->dev; tmp++)
put_device(tmp->dev);
This should just pair with the of_node_put() calls (other than the first one, of course), i.e. do it in the success path as well and drop the release_device change below. It doesn't serve any purpose for client devices to hold additional references on the IOMMU device when those are strictly within the lifetime of the IOMMU driver being bound to it anyway.
I kept the reference until release() (even if not strictly needed) as I mistakenly thought the driver was using the arch data device pointer directly.
Turns out that one has never been used so I'll drop it as well as part of v2.
Johan