iommu: Use right function to get group for device
authorLu Baolu <baolu.lu@linux.intel.com>
Tue, 21 May 2019 07:27:35 +0000 (15:27 +0800)
committerJoerg Roedel <jroedel@suse.de>
Mon, 27 May 2019 14:30:59 +0000 (16:30 +0200)
The iommu_group_get_for_dev() will allocate a group for a
device if it isn't in any group. This isn't the use case
in iommu_request_dm_for_dev(). Let's use iommu_group_get()
instead.

Fixes: d290f1e70d85a ("iommu: Introduce iommu_request_dm_for_dev()")
Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
Signed-off-by: Joerg Roedel <jroedel@suse.de>
drivers/iommu/iommu.c

index 67ee6623f9b2a4d07dcae56dfb99fcf6e4edbb0d..3fa025f849e92cce5a98a756e5589eb48f2c02f7 100644 (file)
@@ -1915,9 +1915,9 @@ int iommu_request_dm_for_dev(struct device *dev)
        int ret;
 
        /* Device must already be in a group before calling this function */
-       group = iommu_group_get_for_dev(dev);
-       if (IS_ERR(group))
-               return PTR_ERR(group);
+       group = iommu_group_get(dev);
+       if (!group)
+               return -EINVAL;
 
        mutex_lock(&group->mutex);