Skip to content

Commit

Permalink
iommu/vt-d: Fix up error handling in alloc_iommu
Browse files Browse the repository at this point in the history
Only check for error when iommu->iommu_dev has been assigned
and only assign drhd->iommu when the function can't fail
anymore.

Signed-off-by: Joerg Roedel <jroedel@suse.de>
  • Loading branch information
Joerg Roedel committed Jan 7, 2016
1 parent 5920337 commit bc84745
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions drivers/iommu/dmar.c
Original file line number Diff line number Diff line change
Expand Up @@ -1063,19 +1063,19 @@ static int alloc_iommu(struct dmar_drhd_unit *drhd)

raw_spin_lock_init(&iommu->register_lock);

drhd->iommu = iommu;

if (intel_iommu_enabled)
if (intel_iommu_enabled) {
iommu->iommu_dev = iommu_device_create(NULL, iommu,
intel_iommu_groups,
"%s", iommu->name);

if (IS_ERR(iommu->iommu_dev)) {
drhd->iommu = NULL;
err = PTR_ERR(iommu->iommu_dev);
goto err_unmap;
if (IS_ERR(iommu->iommu_dev)) {
err = PTR_ERR(iommu->iommu_dev);
goto err_unmap;
}
}

drhd->iommu = iommu;

return 0;

err_unmap:
Expand Down

0 comments on commit bc84745

Please sign in to comment.