Bing Song noticed the CMA heap was leaking memory due to a flub
I made in commit a5d2d29e24be ("dma-buf: heaps: Move heap-helper
logic into the cma_heap implementation"), and provided this fix
which ensures the pagelist is also freed on release.

Cc: Bing Song <bing.s...@nxp.com>
Cc: Sumit Semwal <sumit.sem...@linaro.org>
Cc: Liam Mark <lm...@codeaurora.org>
Cc: Laura Abbott <labb...@kernel.org>
Cc: Brian Starkey <brian.star...@arm.com>
Cc: Hridya Valsaraju <hri...@google.com>
Cc: Suren Baghdasaryan <sur...@google.com>
Cc: Sandeep Patil <sspa...@google.com>
Cc: Daniel Mentz <danielme...@google.com>
Cc: Chris Goldsworthy <cgold...@codeaurora.org>
Cc: Ørjan Eide <orjan.e...@arm.com>
Cc: Robin Murphy <robin.mur...@arm.com>
Cc: Ezequiel Garcia <ezequ...@collabora.com>
Cc: Simon Ser <cont...@emersion.fr>
Cc: James Jones <jajo...@nvidia.com>
Cc: linux-me...@vger.kernel.org
Cc: dri-devel@lists.freedesktop.org
Reported-by: Bing Song <bing.s...@nxp.com>
Fixes: a5d2d29e24be ("dma-buf: heaps: Move heap-helper logic into the cma_heap 
implementation")
Signed-off-by: John Stultz <john.stu...@linaro.org>
---
 drivers/dma-buf/heaps/cma_heap.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/dma-buf/heaps/cma_heap.c b/drivers/dma-buf/heaps/cma_heap.c
index 3c4e34301172..364fc2f3e499 100644
--- a/drivers/dma-buf/heaps/cma_heap.c
+++ b/drivers/dma-buf/heaps/cma_heap.c
@@ -251,6 +251,9 @@ static void cma_heap_dma_buf_release(struct dma_buf *dmabuf)
                buffer->vaddr = NULL;
        }
 
+       /* free page list */
+       kfree(buffer->pages);
+       /* release memory */
        cma_release(cma_heap->cma, buffer->cma_pages, buffer->pagecount);
        kfree(buffer);
 }
-- 
2.17.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Reply via email to