From: Liang He <windhl@126.com>
To: linux@armlinux.org.uk, rmk+kernel@armlinux.org.uk,
wangkefeng.wang@huawei.com, ardb@kernel.org, arnd@arndb.de,
akpm@linux-foundation.org, rppt@kernel.org
Cc: windhl@126.com, linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org
Subject: [PATCH v3] arm/mm: Fix refcount leak bugs in cache
Date: Sun, 19 Jun 2022 09:39:41 +0800 [thread overview]
Message-ID: <20220619013941.4061894-1-windhl@126.com> (raw)
In feroceon_of_init() and tauros2_init(), of_find_matching_node()
will return a node pointer with refcount incremented. We should
use of_node_put() in fail path or when it is not used anymore.
Signed-off-by: Liang He <windhl@126.com>
---
changelog:
v3: (1) merge arm/mm leak bugs (2) fix bugs intro-ed by v2
v2: (1) use real name (2) normalize coding style
v1: (1) fix leak bug
arch/arm/mm/cache-feroceon-l2.c | 6 +++++-
arch/arm/mm/cache-tauros2.c | 1 +
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/arch/arm/mm/cache-feroceon-l2.c b/arch/arm/mm/cache-feroceon-l2.c
index 5c1b7a7b9af6..d5b7878094fd 100644
--- a/arch/arm/mm/cache-feroceon-l2.c
+++ b/arch/arm/mm/cache-feroceon-l2.c
@@ -376,8 +376,10 @@ int __init feroceon_of_init(void)
node = of_find_matching_node(NULL, feroceon_ids);
if (node && of_device_is_compatible(node, "marvell,kirkwood-cache")) {
base = of_iomap(node, 0);
- if (!base)
+ if (!base) {
+ of_node_put(node);
return -ENOMEM;
+ }
if (l2_wt_override)
writel(readl(base) | L2_WRITETHROUGH_KIRKWOOD, base);
@@ -385,6 +387,8 @@ int __init feroceon_of_init(void)
writel(readl(base) & ~L2_WRITETHROUGH_KIRKWOOD, base);
}
+ of_node_put(node);
+
feroceon_l2_init(l2_wt_override);
return 0;
diff --git a/arch/arm/mm/cache-tauros2.c b/arch/arm/mm/cache-tauros2.c
index 88255bea65e4..05eab6e44cfc 100644
--- a/arch/arm/mm/cache-tauros2.c
+++ b/arch/arm/mm/cache-tauros2.c
@@ -294,6 +294,7 @@ void __init tauros2_init(unsigned int features)
pr_info("Not found marvell,tauros2-cache, disable it\n");
} else {
ret = of_property_read_u32(node, "marvell,tauros2-cache-features", &f);
+ of_node_put(node);
if (ret) {
pr_info("Not found marvell,tauros-cache-features property, "
"disable extra features\n");
--
2.25.1
next reply other threads:[~2022-06-19 1:41 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-19 1:39 Liang He [this message]
2022-06-22 8:58 ` 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=20220619013941.4061894-1-windhl@126.com \
--to=windhl@126.com \
--cc=akpm@linux-foundation.org \
--cc=ardb@kernel.org \
--cc=arnd@arndb.de \
--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=rppt@kernel.org \
--cc=wangkefeng.wang@huawei.com \
/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®