diff options
-rw-r--r-- | drivers/iommu/iommu.c | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c index 08c53c5a046f..02e4313e937c 100644 --- a/drivers/iommu/iommu.c +++ b/drivers/iommu/iommu.c | |||
@@ -818,7 +818,15 @@ static int iommu_bus_init(struct bus_type *bus, const struct iommu_ops *ops) | |||
818 | kfree(nb); | 818 | kfree(nb); |
819 | return err; | 819 | return err; |
820 | } | 820 | } |
821 | return bus_for_each_dev(bus, NULL, &cb, add_iommu_group); | 821 | |
822 | err = bus_for_each_dev(bus, NULL, &cb, add_iommu_group); | ||
823 | if (err) { | ||
824 | bus_unregister_notifier(bus, nb); | ||
825 | kfree(nb); | ||
826 | return err; | ||
827 | } | ||
828 | |||
829 | return 0; | ||
822 | } | 830 | } |
823 | 831 | ||
824 | /** | 832 | /** |
@@ -836,13 +844,19 @@ static int iommu_bus_init(struct bus_type *bus, const struct iommu_ops *ops) | |||
836 | */ | 844 | */ |
837 | int bus_set_iommu(struct bus_type *bus, const struct iommu_ops *ops) | 845 | int bus_set_iommu(struct bus_type *bus, const struct iommu_ops *ops) |
838 | { | 846 | { |
847 | int err; | ||
848 | |||
839 | if (bus->iommu_ops != NULL) | 849 | if (bus->iommu_ops != NULL) |
840 | return -EBUSY; | 850 | return -EBUSY; |
841 | 851 | ||
842 | bus->iommu_ops = ops; | 852 | bus->iommu_ops = ops; |
843 | 853 | ||
844 | /* Do IOMMU specific setup for this bus-type */ | 854 | /* Do IOMMU specific setup for this bus-type */ |
845 | return iommu_bus_init(bus, ops); | 855 | err = iommu_bus_init(bus, ops); |
856 | if (err) | ||
857 | bus->iommu_ops = NULL; | ||
858 | |||
859 | return err; | ||
846 | } | 860 | } |
847 | EXPORT_SYMBOL_GPL(bus_set_iommu); | 861 | EXPORT_SYMBOL_GPL(bus_set_iommu); |
848 | 862 | ||