hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/drivers/iommu/mtk_iommu_v1.c
....@@ -618,18 +618,34 @@
618618 ret = iommu_device_sysfs_add(&data->iommu, &pdev->dev, NULL,
619619 dev_name(&pdev->dev));
620620 if (ret)
621
- return ret;
621
+ goto out_clk_unprepare;
622622
623623 iommu_device_set_ops(&data->iommu, &mtk_iommu_ops);
624624
625625 ret = iommu_device_register(&data->iommu);
626626 if (ret)
627
- return ret;
627
+ goto out_sysfs_remove;
628628
629
- if (!iommu_present(&platform_bus_type))
630
- bus_set_iommu(&platform_bus_type, &mtk_iommu_ops);
629
+ if (!iommu_present(&platform_bus_type)) {
630
+ ret = bus_set_iommu(&platform_bus_type, &mtk_iommu_ops);
631
+ if (ret)
632
+ goto out_dev_unreg;
633
+ }
631634
632
- return component_master_add_with_match(dev, &mtk_iommu_com_ops, match);
635
+ ret = component_master_add_with_match(dev, &mtk_iommu_com_ops, match);
636
+ if (ret)
637
+ goto out_bus_set_null;
638
+ return ret;
639
+
640
+out_bus_set_null:
641
+ bus_set_iommu(&platform_bus_type, NULL);
642
+out_dev_unreg:
643
+ iommu_device_unregister(&data->iommu);
644
+out_sysfs_remove:
645
+ iommu_device_sysfs_remove(&data->iommu);
646
+out_clk_unprepare:
647
+ clk_disable_unprepare(data->bclk);
648
+ return ret;
633649 }
634650
635651 static int mtk_iommu_remove(struct platform_device *pdev)