lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <tencent_43768D3DB24034B62C249781C1DE7359C807@qq.com>
Date: Fri, 12 Sep 2025 18:10:05 +0800
From: Haofeng Li <920484857@...com>
To: david@...hat.com,
	Andrew Morton <akpm@...ux-foundation.org>
Cc: 13266079573@....com,
	920484857@...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

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.

Best regards,
	Haofeng Li


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ