]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
ARM: dma-mapping: free allocated page if unable to map
authorRussell King <rmk+kernel@arm.linux.org.uk>
Thu, 22 Sep 2011 09:32:25 +0000 (10:32 +0100)
committerGreg Kroah-Hartman <gregkh@suse.de>
Mon, 3 Oct 2011 18:41:06 +0000 (11:41 -0700)
commit d8e89b47e00ee80e920761145144640aac4cf71a upstream.

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.

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>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
arch/arm/mm/dma-mapping.c

index 82a093cee09a781677ebf639a6450bcd9f4e59fd..f96d2c7300207ee8bd47b4ba4b19abe49f4bee06 100644 (file)
@@ -322,6 +322,8 @@ __dma_alloc(struct device *dev, size_t size, dma_addr_t *handle, gfp_t gfp,
 
        if (addr)
                *handle = pfn_to_dma(dev, page_to_pfn(page));
+       else
+               __dma_free_buffer(page, size);
 
        return addr;
 }