Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit bc847454 authored by Joerg Roedel's avatar Joerg Roedel
Browse files

iommu/vt-d: Fix up error handling in alloc_iommu



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: default avatarJoerg Roedel <jroedel@suse.de>
parent 59203379
Loading
Loading
Loading
Loading
+7 −7
Original line number Diff line number Diff line
@@ -1063,18 +1063,18 @@ 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;
		}
	}

	drhd->iommu = iommu;

	return 0;