[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <85eb9053-0ce4-2514-06dc-58b8910dc5f7@arm.com>
Date: Thu, 25 Nov 2021 13:28:33 +0000
From: Robin Murphy <robin.murphy@....com>
To: guangming.cao@...iatek.com, Sumit Semwal <sumit.semwal@...aro.org>,
Benjamin Gaignard <benjamin.gaignard@...aro.org>,
Liam Mark <lmark@...eaurora.org>,
Laura Abbott <labbott@...hat.com>,
Brian Starkey <Brian.Starkey@....com>,
John Stultz <john.stultz@...aro.org>,
Christian König <christian.koenig@....com>,
Matthias Brugger <matthias.bgg@...il.com>,
"open list:DMA-BUF HEAPS FRAMEWORK" <linux-media@...r.kernel.org>,
"open list:DMA-BUF HEAPS FRAMEWORK" <dri-devel@...ts.freedesktop.org>,
"moderated list:DMA-BUF HEAPS FRAMEWORK"
<linaro-mm-sig@...ts.linaro.org>,
open list <linux-kernel@...r.kernel.org>,
"moderated list:ARM/Mediatek SoC support"
<linux-arm-kernel@...ts.infradead.org>,
"moderated list:ARM/Mediatek SoC support"
<linux-mediatek@...ts.infradead.org>
Cc: wsd_upstream@...iatek.com
Subject: Re: [PATCH] dma_heap: use sg_table.orig_nents in sg_table release
flow
On 2021-11-25 12:46, guangming.cao@...iatek.com wrote:
> From: Guangming <Guangming.Cao@...iatek.com>
>
> Use (sg_table.orig_nents) rather than (sg_table.nents) to traverse
> sg_table to free sg_table.
> Use (sg_table.nents) maybe will casuse some pages can't be freed.
...and this sort of bug is precisely why we have the
for_each_sgtable_sg() helper ;)
Robin.
> Signed-off-by: Guangming <Guangming.Cao@...iatek.com>
> ---
> drivers/dma-buf/heaps/system_heap.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/dma-buf/heaps/system_heap.c b/drivers/dma-buf/heaps/system_heap.c
> index 23a7e74ef966..ce10d4eb674c 100644
> --- a/drivers/dma-buf/heaps/system_heap.c
> +++ b/drivers/dma-buf/heaps/system_heap.c
> @@ -289,7 +289,7 @@ static void system_heap_dma_buf_release(struct dma_buf *dmabuf)
> int i;
>
> table = &buffer->sg_table;
> - for_each_sg(table->sgl, sg, table->nents, i) {
> + for_each_sg(table->sgl, sg, table->orig_nents, i) {
> struct page *page = sg_page(sg);
>
> __free_pages(page, compound_order(page));
>
Powered by blists - more mailing lists