iommu: Check for iommu_ops == NULL in iommu_probe_device()
authorJoerg Roedel <jroedel@suse.de>
Thu, 20 Dec 2018 09:02:20 +0000 (10:02 +0100)
committerJoerg Roedel <jroedel@suse.de>
Thu, 20 Dec 2018 09:02:20 +0000 (10:02 +0100)
This check needs to be there and got lost at some point
during development. Add it again.

Fixes: 641fb0efbff0 ('iommu/of: Don't call iommu_ops->add_device directly')
Reported-by: Marek Szyprowski <m.szyprowski@samsung.com>
Reported-by: kernelci.org bot <bot@kernelci.org>
Signed-off-by: Joerg Roedel <jroedel@suse.de>
drivers/iommu/iommu.c

index a213175..3ed4db3 100644 (file)
@@ -114,10 +114,14 @@ void iommu_device_unregister(struct iommu_device *iommu)
 int iommu_probe_device(struct device *dev)
 {
        const struct iommu_ops *ops = dev->bus->iommu_ops;
+       int ret = -EINVAL;
 
        WARN_ON(dev->iommu_group);
 
-       return ops->add_device(dev);
+       if (ops)
+               ret = ops->add_device(dev);
+
+       return ret;
 }
 
 void iommu_release_device(struct device *dev)