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 <kees@ijzerbout.nl> Link: https://lore.kernel.org/r/20241218201048.E544818E57E@bout3.ijzerbout.nl Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com> Signed-off-by: Joerg Roedel <jroedel@suse.de> Signed-off-by: Amelia Crate <acrate@waldn.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 1e9ad8e commit 68ec78b

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

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)