Skip to content

Commit 68ec78b

Browse files
keestuxgregkh
authored andcommitted
iommu/vt-d: Avoid use of NULL after WARN_ON_ONCE
[ Upstream commit 60f030f ] 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: Kees Bakker <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Lu Baolu <[email protected]> Signed-off-by: Joerg Roedel <[email protected]> Signed-off-by: Amelia Crate <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 1e9ad8e commit 68ec78b

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

drivers/iommu/intel/iommu.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4328,13 +4328,14 @@ static void intel_iommu_remove_dev_pasid(struct device *dev, ioasid_t pasid,
43284328
break;
43294329
}
43304330
}
4331-
WARN_ON_ONCE(!dev_pasid);
43324331
spin_unlock_irqrestore(&dmar_domain->lock, flags);
43334332

43344333
cache_tag_unassign_domain(dmar_domain, dev, pasid);
43354334
domain_detach_iommu(dmar_domain, iommu);
4336-
intel_iommu_debugfs_remove_dev_pasid(dev_pasid);
4337-
kfree(dev_pasid);
4335+
if (!WARN_ON_ONCE(!dev_pasid)) {
4336+
intel_iommu_debugfs_remove_dev_pasid(dev_pasid);
4337+
kfree(dev_pasid);
4338+
}
43384339
intel_pasid_tear_down_entry(iommu, dev, pasid, false);
43394340
intel_drain_pasid_prq(dev, pasid);
43404341
}

0 commit comments

Comments
 (0)