Re: [PATCH v2 4/4] dma-buf: heaps: Fix shared system heap allocation rollback

Jason Gunthorpe <[email protected]>
Newsgroups org.kernel.vger.linux-media,org.freedesktop.lists.dri-devel,org.infradead.lists.linux-arm-kernel,org.kernel.vger.linux-kernel
Message-ID <[email protected]>
On Thu, Aug 20, 2026 at 04:00:33PM +0100, Steven Price wrote:
> If converting one of the allocated pages to shared memory fails, the
> cleanup path attempts to convert every page back to private memory.
> Pages after the failed page have not been converted yet, so attempting
> to convert them back can fail and cause otherwise reusable memory to be
> leaked.
> 
> Count the pages converted successfully and only convert those and the
> failed allocation back during cleanup. If converting the failed
> allocation back succeeds it can be freed safely; otherwise it is leaked
> because its state is unknown. Allocations that were not converted can be
> freed directly.
> 
> Fixes: 78b30c50a7ac ("dma-buf: heaps: system: add system_cc_shared heap for explicitly shared memory")
> Signed-off-by: Steven Price <[email protected]>
> ---
>  drivers/dma-buf/heaps/system_heap.c | 10 +++++++---
>  1 file changed, 7 insertions(+), 3 deletions(-)

Reviewed-by: Jason Gunthorpe <[email protected]>

Jason
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.