diff mbox series

iommu/of: Fix probe-deferral

Message ID b158bd8aae8e9fd1a7fc7960cf17fa623dd47b11.1546880690.git.robin.murphy@arm.com (mailing list archive)
State Mainlined, archived
Commit e8e683ae9a736407a20135df7809090a446db707
Headers show
Series iommu/of: Fix probe-deferral | expand

Commit Message

Robin Murphy Jan. 7, 2019, 5:04 p.m. UTC
Whilst iommu_probe_device() does check for non-NULL ops as the previous
code did, it does not do so in the same order relative to the other
checks, and as a result means that -EPROBE_DEFER returned by of_xlate()
(plus any real error condition too) gets overwritten with -EINVAL and
leads to various misbehaviour.

Reinstate the original logic, but without implicitly relying on ops
being set to infer !err as the initial condition (now that the validity
of ops for its own sake is checked elsewhere).

Fixes: 641fb0efbff0 ("iommu/of: Don't call iommu_ops->add_device directly")
Signed-off-by: Robin Murphy <robin.murphy@arm.com>
---
 drivers/iommu/of_iommu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Joerg Roedel Jan. 11, 2019, 11:28 a.m. UTC | #1
On Mon, Jan 07, 2019 at 05:04:50PM +0000, Robin Murphy wrote:
> Whilst iommu_probe_device() does check for non-NULL ops as the previous
> code did, it does not do so in the same order relative to the other
> checks, and as a result means that -EPROBE_DEFER returned by of_xlate()
> (plus any real error condition too) gets overwritten with -EINVAL and
> leads to various misbehaviour.
> 
> Reinstate the original logic, but without implicitly relying on ops
> being set to infer !err as the initial condition (now that the validity
> of ops for its own sake is checked elsewhere).
> 
> Fixes: 641fb0efbff0 ("iommu/of: Don't call iommu_ops->add_device directly")
> Signed-off-by: Robin Murphy <robin.murphy@arm.com>

Applied to iommu/fixes, thanks.
diff mbox series

Patch

diff --git a/drivers/iommu/of_iommu.c b/drivers/iommu/of_iommu.c
index d8947b28db2d..f04a6df65eb8 100644
--- a/drivers/iommu/of_iommu.c
+++ b/drivers/iommu/of_iommu.c
@@ -224,7 +224,7 @@  const struct iommu_ops *of_iommu_configure(struct device *dev,
 	 * If we have reason to believe the IOMMU driver missed the initial
 	 * probe for dev, replay it to get things in order.
 	 */
-	if (dev->bus && !device_iommu_mapped(dev))
+	if (!err && dev->bus && !device_iommu_mapped(dev))
 		err = iommu_probe_device(dev);
 
 	/* Ignore all other errors apart from EPROBE_DEFER */