diff options
author | Yong Wu <yong.wu@mediatek.com> | 2021-04-12 14:48:43 +0800 |
---|---|---|
committer | Joerg Roedel <jroedel@suse.de> | 2021-04-16 17:15:20 +0200 |
commit | ac304c070c54413efabf29f9e73c54576d329774 (patch) | |
tree | cc1a2fbd130fb9cb94f074ae2cb1db67b0a4479e /drivers/iommu | |
parent | f90a9a85fb946e11092f8ca43e30210a2d427bf4 (diff) | |
download | linux-ac304c070c54413efabf29f9e73c54576d329774.tar.bz2 |
iommu/mediatek-v1: Add error handle for mtk_iommu_probe
In the original code, we lack the error handle. This patch adds them.
Signed-off-by: Yong Wu <yong.wu@mediatek.com>
Link: https://lore.kernel.org/r/20210412064843.11614-2-yong.wu@mediatek.com
Signed-off-by: Joerg Roedel <jroedel@suse.de>
Diffstat (limited to 'drivers/iommu')
-rw-r--r-- | drivers/iommu/mtk_iommu_v1.c | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/drivers/iommu/mtk_iommu_v1.c b/drivers/iommu/mtk_iommu_v1.c index bed0bb9d63fd..8ba9a2ec5509 100644 --- a/drivers/iommu/mtk_iommu_v1.c +++ b/drivers/iommu/mtk_iommu_v1.c @@ -620,12 +620,26 @@ static int mtk_iommu_probe(struct platform_device *pdev) ret = iommu_device_register(&data->iommu); if (ret) - return ret; + goto out_sysfs_remove; - if (!iommu_present(&platform_bus_type)) - bus_set_iommu(&platform_bus_type, &mtk_iommu_ops); + if (!iommu_present(&platform_bus_type)) { + ret = bus_set_iommu(&platform_bus_type, &mtk_iommu_ops); + if (ret) + goto out_dev_unreg; + } - return component_master_add_with_match(dev, &mtk_iommu_com_ops, match); + ret = component_master_add_with_match(dev, &mtk_iommu_com_ops, match); + if (ret) + goto out_bus_set_null; + return ret; + +out_bus_set_null: + bus_set_iommu(&platform_bus_type, NULL); +out_dev_unreg: + iommu_device_unregister(&data->iommu); +out_sysfs_remove: + iommu_device_sysfs_remove(&data->iommu); + return ret; } static int mtk_iommu_remove(struct platform_device *pdev) |