
From: Joerg Roedel <jroedel@suse.de> mainline inclusion from mainline-v4.20-rc1 commit dc9de8a2b20f495696330d60a289935f36407995 category:bugfix bugzilla:NA CVE:NA ------------------- 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> Signed-off-by: Chen Jun <chenjun102@huawei.com> Reviewed-by: Hanjun Guo <guohanjun@huawei.com> Signed-off-by: Yang Yingliang <yangyingliang@huawei.com> --- drivers/iommu/iommu.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c index 0f420fc6fc29..a5a27ba0048b 100644 --- a/drivers/iommu/iommu.c +++ b/drivers/iommu/iommu.c @@ -115,10 +115,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) -- 2.25.1