[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <3f739d3e-f6fc-4a3f-9bbb-151a6dc6c083@redhat.com>
Date: Fri, 12 Sep 2025 13:36:03 +0200
From: David Hildenbrand <david@...hat.com>
To: Haofeng Li <920484857@...com>, Andrew Morton <akpm@...ux-foundation.org>
Cc: 13266079573@....com, lihaofeng@...inos.cn, linux-kernel@...r.kernel.org,
linux-kselftest@...r.kernel.org, linux-mm@...ck.org,
lorenzo.stoakes@...cle.com, ziy@...dia.com
Subject: Re: [PATCH] mm: transhuge-stress: fix potential memory leak on
realloc failure
On 12.09.25 12:10, Haofeng Li wrote:
> From: David Hildenbrand <david@...hat.com>
>> What do you think happens when a process exits? :)
>
>> Correct! All memory ever allocated to that process gets freed, avoiding
>> any memory leaks.
>
> Thanks for pointing this out. You are absolutely correct that the operating system will reclaim all allocated memory when a process exits, so there is no persistent memory leak in this specific scenario.
>
> I opted to add explicit memory freeing in the error path primarily as a practice for better long-term maintainability:
>
> It ensures correctness if the code structure changes in the future (e.g., becomes part of a longer-running routine).
>
> It maintains consistency with other error paths in the codebase.
>
> It prevents false positives from static analysis tools (like valgrind).
>
> I'm happy to adjust it if you still think it's preferable to remove the free() in this context.
No code changes are required. This patch adds more complexity without
any benefit.
--
Cheers
David / dhildenb
Powered by blists - more mailing lists