Skip to content

Commit

Permalink
x86/amd_gart: fix unmapping of non-GART mappings
Browse files Browse the repository at this point in the history
In many cases we don't have to create a GART mapping at all, which
also means there is nothing to unmap.  Fix the range check that was
incorrectly modified when removing the mapping_error method.

Fixes: 9e8aa6b ("x86/amd_gart: remove the mapping_error dma_map_ops method")
Reported-by: Michal Kubecek <mkubecek@suse.cz>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Tested-by: Michal Kubecek <mkubecek@suse.cz>
  • Loading branch information
Christoph Hellwig committed Jan 5, 2019
1 parent 48e638f commit 06f55fd
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion arch/x86/kernel/amd_gart_64.c
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,15 @@ static void gart_unmap_page(struct device *dev, dma_addr_t dma_addr,
int npages;
int i;

if (dma_addr == DMA_MAPPING_ERROR ||
if (WARN_ON_ONCE(dma_addr == DMA_MAPPING_ERROR))
return;

/*
* This driver will not always use a GART mapping, but might have
* created a direct mapping instead. If that is the case there is
* nothing to unmap here.
*/
if (dma_addr < iommu_bus_base ||
dma_addr >= iommu_bus_base + iommu_size)
return;

Expand Down

0 comments on commit 06f55fd

Please sign in to comment.