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-next>] [day] [month] [year] [list]
Message-ID: <20240712094448.159784-1-vincenzo.mezzela@gmail.com>
Date: Fri, 12 Jul 2024 11:44:48 +0200
From: Vincenzo Mezzela <vincenzo.mezzela@...il.com>
To: linux@...linux.org.uk,
	robh@...nel.org,
	rmk+kernel@...linux.org.uk
Cc: linux-arm-kernel@...ts.infradead.org,
	linux-kernel@...r.kernel.org,
	javier.carrasco.cruz@...il.com,
	skhan@...uxfoundation.org,
	Vincenzo Mezzela <vincenzo.mezzela@...il.com>
Subject: [PATCH 1/1] arm: devtree: fix missing device_node cleanup

Device node `cpus` is allocated but never released using `of_node_put`.

This patch introduces the __free attribute for `cpus` device_node that
automatically handle the cleanup of the resource by adding a call to
`of_node_put` at the end of the current scope. This enhancement aims to
mitigate memory management issues associated with forgetting to release
the resources.

Signed-off-by: Vincenzo Mezzela <vincenzo.mezzela@...il.com>
---
 arch/arm/kernel/devtree.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/arm/kernel/devtree.c b/arch/arm/kernel/devtree.c
index fdb74e64206a..223d66a5fff3 100644
--- a/arch/arm/kernel/devtree.c
+++ b/arch/arm/kernel/devtree.c
@@ -70,14 +70,14 @@ void __init arm_dt_init_cpu_maps(void)
 	 * contain a list of MPIDR[23:0] values where MPIDR[31:24] must
 	 * read as 0.
 	 */
-	struct device_node *cpu, *cpus;
 	int found_method = 0;
 	u32 i, j, cpuidx = 1;
 	u32 mpidr = is_smp() ? read_cpuid_mpidr() & MPIDR_HWID_BITMASK : 0;
 
 	u32 tmp_map[NR_CPUS] = { [0 ... NR_CPUS-1] = MPIDR_INVALID };
 	bool bootcpu_valid = false;
-	cpus = of_find_node_by_path("/cpus");
+	struct device_node *cpu;
+	struct device_node *cpus __free(device_node) = of_find_node_by_path("/cpus");
 
 	if (!cpus)
 		return;
-- 
2.43.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ