]> Git Repo - linux.git/commitdiff
iommu: Check the result of iommu_group_get() for NULL
authorJordan Crouse <[email protected]>
Wed, 20 Dec 2017 16:48:36 +0000 (09:48 -0700)
committerAlex Williamson <[email protected]>
Wed, 20 Dec 2017 16:48:36 +0000 (09:48 -0700)
The result of iommu_group_get() was being blindly used in both
attach and detach which results in a dereference when trying
to work with an unknown device.

Signed-off-by: Jordan Crouse <[email protected]>
Signed-off-by: Alex Williamson <[email protected]>
drivers/iommu/iommu.c

index 3de5c0bcb5cc9f32b6fb615ce38f5729ae86d407..69fef991c651de26c60e5c3cb5f2e6be0c0d0fcb 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) {
This page took 0.065171 seconds and 4 git commands to generate.