Skip to content

Commit 679d94c

Browse files
Guangmingsumitsemwal
authored andcommitted
dma-buf: system_heap: Use 'for_each_sgtable_sg' in pages free flow
For previous version, it uses 'sg_table.nent's to traverse sg_table in pages free flow. However, 'sg_table.nents' is reassigned in 'dma_map_sg', it means the number of created entries in the DMA adderess space. So, use 'sg_table.nents' in pages free flow will case some pages can't be freed. Here we should use sg_table.orig_nents to free pages memory, but use the sgtable helper 'for each_sgtable_sg'(, instead of the previous rather common helper 'for_each_sg' which maybe cause memory leak) is much better. Fixes: d963ab0 ("dma-buf: system_heap: Allocate higher order pages if available") Signed-off-by: Guangming <[email protected]> Reviewed-by: Robin Murphy <[email protected]> Cc: <[email protected]> # 5.11.* Reviewed-by: Christian König <[email protected]> Reviewed-by: John Stultz <[email protected]> Signed-off-by: Sumit Semwal <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent 6052a31 commit 679d94c

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/dma-buf/heaps/system_heap.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ static void system_heap_dma_buf_release(struct dma_buf *dmabuf)
290290
int i;
291291

292292
table = &buffer->sg_table;
293-
for_each_sg(table->sgl, sg, table->nents, i) {
293+
for_each_sgtable_sg(table, sg, i) {
294294
struct page *page = sg_page(sg);
295295

296296
__free_pages(page, compound_order(page));

0 commit comments

Comments
 (0)