Skip to content

Commit

Permalink
iommu: Checking for NULL instead of IS_ERR
Browse files Browse the repository at this point in the history
The iommu_group_alloc() and iommu_group_get_for_dev()
functions return error pointers, they never return NULL.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Joerg Roedel <jroedel@suse.de>
  • Loading branch information
Dan Carpenter authored and Joerg Roedel committed Jun 11, 2015
1 parent 3a18404 commit 409e553
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions drivers/iommu/iommu.c
Original file line number Diff line number Diff line change
@@ -788,15 +788,16 @@ static struct iommu_group *iommu_group_get_for_pci_dev(struct pci_dev *pdev)

/* No shared group found, allocate new */
group = iommu_group_alloc();
if (group) {
/*
* Try to allocate a default domain - needs support from the
* IOMMU driver.
*/
group->default_domain = __iommu_domain_alloc(pdev->dev.bus,
IOMMU_DOMAIN_DMA);
group->domain = group->default_domain;
}
if (IS_ERR(group))
return NULL;

/*
* Try to allocate a default domain - needs support from the
* IOMMU driver.
*/
group->default_domain = __iommu_domain_alloc(pdev->dev.bus,
IOMMU_DOMAIN_DMA);
group->domain = group->default_domain;

return group;
}
@@ -1548,8 +1549,8 @@ int iommu_request_dm_for_dev(struct device *dev)

/* Device must already be in a group before calling this function */
group = iommu_group_get_for_dev(dev);
if (!group)
return -EINVAL;
if (IS_ERR(group))
return PTR_ERR(group);

mutex_lock(&group->mutex);

0 comments on commit 409e553

Please sign in to comment.