Merge tag 'linux-kselftest-4.16-rc5' of git://git.kernel.org/pub/scm/linux/kernel...
[linux-2.6-microblaze.git] / drivers / iommu / iommu.c
index 3de5c0b..69fef99 100644 (file)
@@ -1303,6 +1303,9 @@ int iommu_attach_device(struct iommu_domain *domain, struct device *dev)
        int ret;
 
        group = iommu_group_get(dev);
+       if (!group)
+               return -ENODEV;
+
        /*
         * Lock the group to make sure the device-count doesn't
         * change while we are attaching
@@ -1341,6 +1344,8 @@ void iommu_detach_device(struct iommu_domain *domain, struct device *dev)
        struct iommu_group *group;
 
        group = iommu_group_get(dev);
+       if (!group)
+               return;
 
        mutex_lock(&group->mutex);
        if (iommu_group_device_count(group) != 1) {