Commit 60f030f7 authored by Kees Bakker's avatar Kees Bakker Committed by Joerg Roedel
Browse files

iommu/vt-d: Avoid use of NULL after WARN_ON_ONCE



There is a WARN_ON_ONCE to catch an unlikely situation when
domain_remove_dev_pasid can't find the `pasid`. In case it nevertheless
happens we must avoid using a NULL pointer.

Signed-off-by: default avatarKees Bakker <kees@ijzerbout.nl>
Link: https://lore.kernel.org/r/20241218201048.E544818E57E@bout3.ijzerbout.nl


Signed-off-by: default avatarLu Baolu <baolu.lu@linux.intel.com>
Signed-off-by: default avatarJoerg Roedel <jroedel@suse.de>
parent 78d4f34e
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -4090,14 +4090,15 @@ void domain_remove_dev_pasid(struct iommu_domain *domain,
			break;
		}
	}
	WARN_ON_ONCE(!dev_pasid);
	spin_unlock_irqrestore(&dmar_domain->lock, flags);

	cache_tag_unassign_domain(dmar_domain, dev, pasid);
	domain_detach_iommu(dmar_domain, iommu);
	if (!WARN_ON_ONCE(!dev_pasid)) {
		intel_iommu_debugfs_remove_dev_pasid(dev_pasid);
		kfree(dev_pasid);
	}
}

static void intel_iommu_remove_dev_pasid(struct device *dev, ioasid_t pasid,
					 struct iommu_domain *domain)