From: Liang He <windhl@126.com>
To: linux@armlinux.org.uk, rmk+kernel@armlinux.org.uk,
ardb@kernel.org, linus.walleij@linaro.org, arnd@arndb.de,
rostedt@goodmis.org, ebiederm@xmission.com
Cc: windhl@126.com, linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org
Subject: [PATCH] arm/kernel: Fix refcount leak bugs
Date: Sun, 19 Jun 2022 14:59:41 +0800 [thread overview]
Message-ID: <20220619065941.4066920-1-windhl@126.com> (raw)
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@126.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
next reply other threads:[~2022-06-19 7:01 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-19 6:59 Liang He [this message]
2022-06-22 8:53 ` Krzysztof Kozlowski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220619065941.4066920-1-windhl@126.com \
--to=windhl@126.com \
--cc=ardb@kernel.org \
--cc=arnd@arndb.de \
--cc=ebiederm@xmission.com \
--cc=linus.walleij@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=rmk+kernel@armlinux.org.uk \
--cc=rostedt@goodmis.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®