diff options
author | Russell King <rmk+kernel@arm.linux.org.uk> | 2011-09-22 05:32:25 -0400 |
---|---|---|
committer | Russell King <rmk+kernel@arm.linux.org.uk> | 2011-09-26 04:36:50 -0400 |
commit | d8e89b47e00ee80e920761145144640aac4cf71a (patch) | |
tree | f3d0bd7bf530fe56dc6fba2f7701f0e6b82795d3 /arch/arm/mm | |
parent | 6760b109603c794e4bd281c0014fef069c019b6a (diff) |
ARM: dma-mapping: free allocated page if unable to map
If the attempt to map a page for DMA fails (eg, because we're out of
mapping space) then we must not hold on to the page we allocated for
DMA - doing so will result in a memory leak.
Cc: <stable@kernel.org>
Reported-by: Bryan Phillippe <bp@darkforest.org>
Tested-by: Bryan Phillippe <bp@darkforest.org>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'arch/arm/mm')
-rw-r--r-- | arch/arm/mm/dma-mapping.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c index 0a0a1e7c20d2..c3ff82f92d9c 100644 --- a/arch/arm/mm/dma-mapping.c +++ b/arch/arm/mm/dma-mapping.c | |||
@@ -324,6 +324,8 @@ __dma_alloc(struct device *dev, size_t size, dma_addr_t *handle, gfp_t gfp, | |||
324 | 324 | ||
325 | if (addr) | 325 | if (addr) |
326 | *handle = pfn_to_dma(dev, page_to_pfn(page)); | 326 | *handle = pfn_to_dma(dev, page_to_pfn(page)); |
327 | else | ||
328 | __dma_free_buffer(page, size); | ||
327 | 329 | ||
328 | return addr; | 330 | return addr; |
329 | } | 331 | } |