]> git.baikalelectronics.ru Git - kernel.git/commit
dma-buf: system_heap: Use 'for_each_sgtable_sg' in pages free flow
authorGuangming <Guangming.Cao@mediatek.com>
Fri, 26 Nov 2021 07:49:04 +0000 (15:49 +0800)
committerSumit Semwal <sumit.semwal@linaro.org>
Wed, 1 Dec 2021 10:00:10 +0000 (15:30 +0530)
commit34afcd4dff978b2e529af69fbe7afceedaf22e64
tree4ddd6f579b6f88faa03f35b3e36b5fb0717d61f6
parent0b05d16d9a97c700b0213a9e4a2803bd68f9e6dc
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: 29b5dcea2e196 ("dma-buf: system_heap: Allocate higher order pages if available")
Signed-off-by: Guangming <Guangming.Cao@mediatek.com>
Reviewed-by: Robin Murphy <robin.murphy@arm.com>
Cc: <stable@vger.kernel.org> # 5.11.*
Reviewed-by: Christian König <christian.koenig@amd.com>
Reviewed-by: John Stultz <john.stultz@linaro.org>
Signed-off-by: Sumit Semwal <sumit.semwal@linaro.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20211126074904.88388-1-guangming.cao@mediatek.com
drivers/dma-buf/heaps/system_heap.c