From: Liang He <windhl@126.com>
To: tony@atomide.com, linux@armlinux.org.uk
Cc: windhl@126.com, linux-arm-kernel@lists.infradead.org,
linux-omap@vger.kernel.org
Subject: [PATCH v2] arm/mach-omap2: Fix refcount leak bugs
Date: Mon, 20 Jun 2022 23:54:21 +0800 [thread overview]
Message-ID: <20220620155421.4076532-1-windhl@126.com> (raw)
We need to add of_node_put() to keep refcount balance for of_find_xxx()
which will return a node pointer with refcount incremented.
Signed-off-by: Liang He <windhl@126.com>
---
changelog:
v2:(1) we find several new leak bugs
(2) we merge all mach-omap2 related bugs in to one commit
v1: we send a patch for each missing of_node_put bug
arch/arm/mach-omap2/display.c | 1 +
arch/arm/mach-omap2/omap4-common.c | 1 +
arch/arm/mach-omap2/omap_hwmod.c | 6 ++++++
arch/arm/mach-omap2/pdata-quirks.c | 2 ++
4 files changed, 10 insertions(+)
diff --git a/arch/arm/mach-omap2/display.c b/arch/arm/mach-omap2/display.c
index 21413a9b7b6c..eb09a25e3b45 100644
--- a/arch/arm/mach-omap2/display.c
+++ b/arch/arm/mach-omap2/display.c
@@ -211,6 +211,7 @@ static int __init omapdss_init_fbdev(void)
node = of_find_node_by_name(NULL, "omap4_padconf_global");
if (node)
omap4_dsi_mux_syscon = syscon_node_to_regmap(node);
+ of_node_put(node);
return 0;
}
diff --git a/arch/arm/mach-omap2/omap4-common.c b/arch/arm/mach-omap2/omap4-common.c
index 6d1eb4eefefe..e981bf57e64f 100644
--- a/arch/arm/mach-omap2/omap4-common.c
+++ b/arch/arm/mach-omap2/omap4-common.c
@@ -135,6 +135,7 @@ static int __init omap4_sram_init(void)
pr_warn("%s:Unable to allocate sram needed to handle errata I688\n",
__func__);
sram_pool = of_gen_pool_get(np, "sram", 0);
+ of_node_put(np);
if (!sram_pool)
pr_warn("%s:Unable to get sram pool needed to handle errata I688\n",
__func__);
diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
index 31d1a21f6041..814546c10bb8 100644
--- a/arch/arm/mach-omap2/omap_hwmod.c
+++ b/arch/arm/mach-omap2/omap_hwmod.c
@@ -2365,6 +2365,7 @@ static int __init _init(struct omap_hwmod *oh, void *data)
r = _init_mpu_rt_base(oh, NULL, index, np);
if (r < 0) {
+ of_node_put(bus);
WARN(1, "omap_hwmod: %s: doesn't have mpu register target base\n",
oh->name);
return 0;
@@ -2372,6 +2373,7 @@ static int __init _init(struct omap_hwmod *oh, void *data)
r = _init_clocks(oh, np);
if (r < 0) {
+ of_node_put(bus);
WARN(1, "omap_hwmod: %s: couldn't init clocks\n", oh->name);
return -EINVAL;
}
@@ -2385,6 +2387,8 @@ static int __init _init(struct omap_hwmod *oh, void *data)
parse_module_flags(oh, child);
}
+ of_node_put(bus);
+
oh->_state = _HWMOD_STATE_INITIALIZED;
return 0;
@@ -3648,6 +3652,7 @@ static void __init omap_hwmod_setup_earlycon_flags(void)
np = of_find_node_by_path("/chosen");
if (np) {
uart = of_get_property(np, "stdout-path", NULL);
+ of_node_put(np);
if (uart) {
np = of_find_node_by_path(uart);
if (np) {
@@ -3661,6 +3666,7 @@ static void __init omap_hwmod_setup_earlycon_flags(void)
}
if (oh)
oh->flags |= DEBUG_OMAPUART_FLAGS;
+ of_node_put(np);
}
}
}
diff --git a/arch/arm/mach-omap2/pdata-quirks.c b/arch/arm/mach-omap2/pdata-quirks.c
index 13f1b89f74b8..5b99d602c87b 100644
--- a/arch/arm/mach-omap2/pdata-quirks.c
+++ b/arch/arm/mach-omap2/pdata-quirks.c
@@ -540,6 +540,8 @@ pdata_quirks_init_clocks(const struct of_device_id *omap_dt_match_table)
of_platform_populate(np, omap_dt_match_table,
omap_auxdata_lookup, NULL);
+
+ of_node_put(np);
}
}
--
2.25.1
WARNING: multiple messages have this Message-ID (diff)
From: Liang He <windhl@126.com>
To: tony@atomide.com, linux@armlinux.org.uk
Cc: windhl@126.com, linux-arm-kernel@lists.infradead.org,
linux-omap@vger.kernel.org
Subject: [PATCH v2] arm/mach-omap2: Fix refcount leak bugs
Date: Mon, 20 Jun 2022 23:54:21 +0800 [thread overview]
Message-ID: <20220620155421.4076532-1-windhl@126.com> (raw)
We need to add of_node_put() to keep refcount balance for of_find_xxx()
which will return a node pointer with refcount incremented.
Signed-off-by: Liang He <windhl@126.com>
---
changelog:
v2:(1) we find several new leak bugs
(2) we merge all mach-omap2 related bugs in to one commit
v1: we send a patch for each missing of_node_put bug
arch/arm/mach-omap2/display.c | 1 +
arch/arm/mach-omap2/omap4-common.c | 1 +
arch/arm/mach-omap2/omap_hwmod.c | 6 ++++++
arch/arm/mach-omap2/pdata-quirks.c | 2 ++
4 files changed, 10 insertions(+)
diff --git a/arch/arm/mach-omap2/display.c b/arch/arm/mach-omap2/display.c
index 21413a9b7b6c..eb09a25e3b45 100644
--- a/arch/arm/mach-omap2/display.c
+++ b/arch/arm/mach-omap2/display.c
@@ -211,6 +211,7 @@ static int __init omapdss_init_fbdev(void)
node = of_find_node_by_name(NULL, "omap4_padconf_global");
if (node)
omap4_dsi_mux_syscon = syscon_node_to_regmap(node);
+ of_node_put(node);
return 0;
}
diff --git a/arch/arm/mach-omap2/omap4-common.c b/arch/arm/mach-omap2/omap4-common.c
index 6d1eb4eefefe..e981bf57e64f 100644
--- a/arch/arm/mach-omap2/omap4-common.c
+++ b/arch/arm/mach-omap2/omap4-common.c
@@ -135,6 +135,7 @@ static int __init omap4_sram_init(void)
pr_warn("%s:Unable to allocate sram needed to handle errata I688\n",
__func__);
sram_pool = of_gen_pool_get(np, "sram", 0);
+ of_node_put(np);
if (!sram_pool)
pr_warn("%s:Unable to get sram pool needed to handle errata I688\n",
__func__);
diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
index 31d1a21f6041..814546c10bb8 100644
--- a/arch/arm/mach-omap2/omap_hwmod.c
+++ b/arch/arm/mach-omap2/omap_hwmod.c
@@ -2365,6 +2365,7 @@ static int __init _init(struct omap_hwmod *oh, void *data)
r = _init_mpu_rt_base(oh, NULL, index, np);
if (r < 0) {
+ of_node_put(bus);
WARN(1, "omap_hwmod: %s: doesn't have mpu register target base\n",
oh->name);
return 0;
@@ -2372,6 +2373,7 @@ static int __init _init(struct omap_hwmod *oh, void *data)
r = _init_clocks(oh, np);
if (r < 0) {
+ of_node_put(bus);
WARN(1, "omap_hwmod: %s: couldn't init clocks\n", oh->name);
return -EINVAL;
}
@@ -2385,6 +2387,8 @@ static int __init _init(struct omap_hwmod *oh, void *data)
parse_module_flags(oh, child);
}
+ of_node_put(bus);
+
oh->_state = _HWMOD_STATE_INITIALIZED;
return 0;
@@ -3648,6 +3652,7 @@ static void __init omap_hwmod_setup_earlycon_flags(void)
np = of_find_node_by_path("/chosen");
if (np) {
uart = of_get_property(np, "stdout-path", NULL);
+ of_node_put(np);
if (uart) {
np = of_find_node_by_path(uart);
if (np) {
@@ -3661,6 +3666,7 @@ static void __init omap_hwmod_setup_earlycon_flags(void)
}
if (oh)
oh->flags |= DEBUG_OMAPUART_FLAGS;
+ of_node_put(np);
}
}
}
diff --git a/arch/arm/mach-omap2/pdata-quirks.c b/arch/arm/mach-omap2/pdata-quirks.c
index 13f1b89f74b8..5b99d602c87b 100644
--- a/arch/arm/mach-omap2/pdata-quirks.c
+++ b/arch/arm/mach-omap2/pdata-quirks.c
@@ -540,6 +540,8 @@ pdata_quirks_init_clocks(const struct of_device_id *omap_dt_match_table)
of_platform_populate(np, omap_dt_match_table,
omap_auxdata_lookup, NULL);
+
+ of_node_put(np);
}
}
--
2.25.1
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next reply other threads:[~2022-06-20 15:54 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-20 15:54 Liang He [this message]
2022-06-20 15:54 ` [PATCH v2] arm/mach-omap2: Fix refcount leak bugs Liang He
2022-06-22 8:53 ` Krzysztof Kozlowski
2022-06-22 8:53 ` Krzysztof Kozlowski
2022-06-28 4:05 ` Tony Lindgren
2022-06-28 4:05 ` Tony Lindgren
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=20220620155421.4076532-1-windhl@126.com \
--to=windhl@126.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-omap@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=tony@atomide.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.