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: <20220619065941.4066920-1-windhl@126.com>
Date:   Sun, 19 Jun 2022 14:59:41 +0800
From:   Liang He <windhl@....com>
To:     linux@...linux.org.uk, rmk+kernel@...linux.org.uk, ardb@...nel.org,
        linus.walleij@...aro.org, arnd@...db.de, rostedt@...dmis.org,
        ebiederm@...ssion.com
Cc:     windhl@....com, linux-arm-kernel@...ts.infradead.org,
        linux-kernel@...r.kernel.org
Subject: [PATCH] arm/kernel: Fix refcount leak bugs

In arm_dt_init_cpu_maps() and init_machine_late(), we need of_node_put()
to keep refcount balance.

Signed-off-by: Liang He <windhl@....com>
---
 arch/arm/kernel/devtree.c | 4 ++++
 arch/arm/kernel/setup.c   | 1 +
 2 files changed, 5 insertions(+)

diff --git a/arch/arm/kernel/devtree.c b/arch/arm/kernel/devtree.c
index 02839d8b6202..d4dbc9eb382d 100644
--- a/arch/arm/kernel/devtree.c
+++ b/arch/arm/kernel/devtree.c
@@ -94,6 +94,7 @@ void __init arm_dt_init_cpu_maps(void)
 		 */
 		if (hwid & ~MPIDR_HWID_BITMASK) {
 			of_node_put(cpu);
+			of_node_put(cpus);
 			return;
 		}
 
@@ -108,6 +109,7 @@ void __init arm_dt_init_cpu_maps(void)
 			if (WARN(tmp_map[j] == hwid,
 				 "Duplicate /cpu reg properties in the DT\n")) {
 				of_node_put(cpu);
+				of_node_put(cpus);
 				return;
 			}
 
@@ -148,6 +150,8 @@ void __init arm_dt_init_cpu_maps(void)
 	if (!found_method)
 		set_smp_ops_by_method(cpus);
 
+	of_node_put(cpus);
+
 	if (!bootcpu_valid) {
 		pr_warn("DT missing boot CPU MPIDR[23:0], fall back to default cpu_logical_map\n");
 		return;
diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c
index 1e8a50a97edf..43ec8d78c219 100644
--- a/arch/arm/kernel/setup.c
+++ b/arch/arm/kernel/setup.c
@@ -960,6 +960,7 @@ static int __init init_machine_late(void)
 	if (root) {
 		ret = of_property_read_string(root, "serial-number",
 					      &system_serial);
+		of_node_put(root);
 		if (ret)
 			system_serial = NULL;
 	}
-- 
2.25.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ