Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1338211

Re: [PATCH 2/2] ARM: dma-mapping: fix alloc/free for coherent + CMA + gfp=0

From Russell King - ARM Linux <linux@arm.linux.org.uk>
Newsgroups linux.kernel
Subject Re: [PATCH 2/2] ARM: dma-mapping: fix alloc/free for coherent + CMA + gfp=0
Date 2016-02-19 15:10 +0100
Message-ID <r3TUS-6ct-13@gated-at.bofh.it> (permalink)
References <r3Osa-295-23@gated-at.bofh.it> <r3Osa-295-21@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Fri, Feb 19, 2016 at 09:12:04AM +0100, Rabin Vincent wrote:
> Given a device which uses arm_coherent_dma_ops and on which
> dev_get_cma_area(dev) returns non-NULL, the following usage of the DMA
> API with gfp=0 results in a memory leak and memory corruption.
> 
>  p = dma_alloc_coherent(dev, sz, &dma, 0);
>  if (p)
>  	dma_free_coherent(dev, sz, p, dma);
> 
> The memory leak is because the alloc allocates using
> __alloc_simple_buffer() but the free attempts
> dma_release_from_contiguous(), which does not do free anything since the
> page is not in the CMA area.

I'd really like to see a better solution to this problem: over the course
of the years, I've seen a number of patches that rearrange the test order
at allocation time because of some problem or the other.

What we need is a better way to ensure that we use the correct release
functionality - having two independent set of tests where the order
matters is really not very good.

Maybe someone can put some thought into this...

-- 
RMK's Patch system: http://www.arm.linux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.

Back to linux.kernel | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

[PATCH 2/2] ARM: dma-mapping: fix alloc/free for coherent + CMA + gfp=0 Rabin Vincent <rabin.vincent@axis.com> - 2016-02-19 09:20 +0100
  Re: [PATCH 2/2] ARM: dma-mapping: fix alloc/free for coherent + CMA + gfp=0 Michal Nazarewicz <mina86@mina86.com> - 2016-02-19 15:00 +0100
  Re: [PATCH 2/2] ARM: dma-mapping: fix alloc/free for coherent + CMA  + gfp=0 Russell King - ARM Linux <linux@arm.linux.org.uk> - 2016-02-19 15:10 +0100

csiph-web