Skip to content

Commit cbf2f9e

Browse files
TinaZhangZWjoergroedel
authored andcommitted
iommu/vt-d: Remove BUG_ON in map/unmap()
Domain map/unmap with invalid parameters shouldn't crash the kernel. Therefore, using if() replaces the BUG_ON. Signed-off-by: Tina Zhang <tina.zhang@intel.com> Link: https://lore.kernel.org/r/20230406065944.2773296-6-tina.zhang@intel.com Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com> Signed-off-by: Joerg Roedel <jroedel@suse.de>
1 parent 998d4c2 commit cbf2f9e

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

drivers/iommu/intel/iommu.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2159,7 +2159,8 @@ __domain_mapping(struct dmar_domain *domain, unsigned long iov_pfn,
21592159
phys_addr_t pteval;
21602160
u64 attr;
21612161

2162-
BUG_ON(!domain_pfn_supported(domain, iov_pfn + nr_pages - 1));
2162+
if (unlikely(!domain_pfn_supported(domain, iov_pfn + nr_pages - 1)))
2163+
return -EINVAL;
21632164

21642165
if ((prot & (DMA_PTE_READ|DMA_PTE_WRITE)) == 0)
21652166
return -EINVAL;
@@ -4314,8 +4315,9 @@ static size_t intel_iommu_unmap(struct iommu_domain *domain,
43144315

43154316
/* Cope with horrid API which requires us to unmap more than the
43164317
size argument if it happens to be a large-page mapping. */
4317-
BUG_ON(!pfn_to_dma_pte(dmar_domain, iova >> VTD_PAGE_SHIFT, &level,
4318-
GFP_ATOMIC));
4318+
if (unlikely(!pfn_to_dma_pte(dmar_domain, iova >> VTD_PAGE_SHIFT,
4319+
&level, GFP_ATOMIC)))
4320+
return 0;
43194321

43204322
if (size < VTD_PAGE_SIZE << level_to_offset_bits(level))
43214323
size = VTD_PAGE_SIZE << level_to_offset_bits(level);

0 commit comments

Comments
 (0)