Skip to content

Commit

Permalink
ARM: DMA-mapping: fix memory leak in IOMMU dma-mapping implementation
Browse files Browse the repository at this point in the history
This patch removes page_address() usage in IOMMU-aware dma-mapping
implementation and replaced it with direct use of the cpu virtual address
provided by the caller. page_address() returned incorrect address for
pages remapped in atomic pool, what caused memory leak.

Reported-by: Hiroshi Doyu <[email protected]>
Signed-off-by: Marek Szyprowski <[email protected]>
Tested-by: Hiroshi Doyu <[email protected]>
  • Loading branch information
mszyprow committed Feb 25, 2013
1 parent 60460ab commit d589829
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions arch/arm/mm/dma-mapping.c
Original file line number Diff line number Diff line change
Expand Up @@ -1292,11 +1292,11 @@ static void *__iommu_alloc_atomic(struct device *dev, size_t size,
return NULL;
}

static void __iommu_free_atomic(struct device *dev, struct page **pages,
static void __iommu_free_atomic(struct device *dev, void *cpu_addr,
dma_addr_t handle, size_t size)
{
__iommu_remove_mapping(dev, handle, size);
__free_from_pool(page_address(pages[0]), size);
__free_from_pool(cpu_addr, size);
}

static void *arm_iommu_alloc_attrs(struct device *dev, size_t size,
Expand Down Expand Up @@ -1379,7 +1379,7 @@ void arm_iommu_free_attrs(struct device *dev, size_t size, void *cpu_addr,
}

if (__in_atomic_pool(cpu_addr, size)) {
__iommu_free_atomic(dev, pages, handle, size);
__iommu_free_atomic(dev, cpu_addr, handle, size);
return;
}

Expand Down

0 comments on commit d589829

Please sign in to comment.