Skip to contentSkip to conversation

arm/kernel: Fix refcount leak bugs

PATCH Superseded Liang He 2 participants 2 messages Jun 19, 2022 – Jun 22, 2022 Arm (32-bit)

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Liang He

author
#0 lore raw

PATCH 1/1 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.

---
 arch/arm/kernel/devtree.c | 4 ++++
 arch/arm/kernel/setup.c   | 1 +
 2 files changed, 5 insertions(+)
arch/arm/kernel/devtree.c +4 -0
index 02839d8b6202..d4dbc9eb382d 100644
@@ -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;
arch/arm/kernel/setup.c +1 -0
index 1e8a50a97edf..43ec8d78c219 100644
@@ -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;
 	}
Signature · 1 line
2.25.1