Skip to contentSkip to conversation

dma-buf: cma_heap: Fix memory leak in CMA heap

PATCH In review John Stultz 2 participants 2 messages Jan 7, 2021 – Jan 9, 2021

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 dma-buf: cma_heap: Fix memory leak in CMA heap

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 <[email protected]>
Cc Sumit Semwal <[email protected]>
Cc Liam Mark <[email protected]>
Cc Laura Abbott <[email protected]>
Cc Brian Starkey <[email protected]>
Cc Hridya Valsaraju <[email protected]>
Cc Suren Baghdasaryan <[email protected]>
Cc Sandeep Patil <[email protected]>
Cc Daniel Mentz <[email protected]>
Cc Chris Goldsworthy <[email protected]>
Cc Ørjan Eide <[email protected]>
Cc Robin Murphy <[email protected]>
Cc Ezequiel Garcia <[email protected]>
Cc Simon Ser <[email protected]>
Cc James Jones <[email protected]>
Fixes a5d2d29e24be ("dma-buf: heaps: Move heap-helper logic into the cma_heap implementation")
---
 drivers/dma-buf/heaps/cma_heap.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/dma-buf/heaps/cma_heap.c +3 -0
index 3c4e34301172..364fc2f3e499 100644
@@ -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);
 }
Signature · 6 lines
2.17.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
maintainer
#1 lore raw

Hi John,

Quoted 5 lines · John Stultz

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.

Thanks for your patch.

Quoted 13 lines
Cc Bing Song <[email protected]>
Cc Sumit Semwal <[email protected]>
Cc Liam Mark <[email protected]>
Cc Laura Abbott <[email protected]>
Cc Brian Starkey <[email protected]>
Cc Hridya Valsaraju <[email protected]>
Cc Suren Baghdasaryan <[email protected]>
Cc Sandeep Patil <[email protected]>
Cc Daniel Mentz <[email protected]>
Cc Chris Goldsworthy <[email protected]>
Cc Ørjan Eide <[email protected]>
Cc Robin Murphy <[email protected]>
Quoted 8 lines
Cc Ezequiel Garcia <[email protected]>
Cc Simon Ser <[email protected]>
Cc James Jones <[email protected]>
Fixes a5d2d29e24be ("dma-buf: heaps: Move heap-helper logic into the cma_heap implementation")

I will queue it up so it gets in the v5.11 cycle.

Quoted 19 lines
---
 drivers/dma-buf/heaps/cma_heap.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/dma-buf/heaps/cma_heap.c +3 -1
index 3c4e34301172..364fc2f3e499 100644
@@ -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);
 }
--
Quoted 2 lines

2.17.1

Best,
Sumit.
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel