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] [day] [month] [year] [list]
Message-ID: <176738979758.226449.11539290980243555444.robh@kernel.org>
Date: Fri, 2 Jan 2026 15:36:38 -0600
From: "Rob Herring (Arm)" <robh@...nel.org>
To: Zilin Guan <zilin@....edu.cn>
Cc: Jianhao Xu <jianhao.xu@....edu.cn>, saravanak@...gle.com,
	devicetree@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2] of: unittest: Fix memory leak in unittest_data_add()


On Wed, 31 Dec 2025 11:49:15 +0000, Zilin Guan wrote:
> In unittest_data_add(), if of_resolve_phandles() fails, the allocated
> unittest_data is not freed, leading to a memory leak.
> 
> Fix this by using scope-based cleanup helper __free(kfree) for automatic
> resource cleanup. This ensures unittest_data is automatically freed when
> it goes out of scope in error paths.
> 
> For the success path, use retain_and_null_ptr() to transfer ownership
> of the memory to the device tree and prevent double freeing.
> 
> Fixes: 2eb46da2a760 ("of/selftest: Use the resolver to fixup phandles")
> Suggested-by: Rob Herring <robh@...nel.org>
> Co-developed-by: Jianhao Xu <jianhao.xu@....edu.cn>
> Signed-off-by: Jianhao Xu <jianhao.xu@....edu.cn>
> Signed-off-by: Zilin Guan <zilin@....edu.cn>
> ---
> Changes in v2:
> - using scope-based cleanup helper __free(kfree) for automatic resource cleanup.
> 
>  drivers/of/unittest.c | 8 +++-----
>  1 file changed, 3 insertions(+), 5 deletions(-)
> 

Applied, thanks!


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ