* [PATCH v3] arm/mm: Fix refcount leak bugs in cache
@ 2022-06-19 1:39 Liang He
2022-06-22 8:58 ` Krzysztof Kozlowski
0 siblings, 1 reply; 2+ messages in thread
From: Liang He @ 2022-06-19 1:39 UTC (permalink / raw)
To: linux, rmk+kernel, wangkefeng.wang, ardb, arnd, akpm, rppt
Cc: windhl, linux-arm-kernel, linux-kernel
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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v3] arm/mm: Fix refcount leak bugs in cache
2022-06-19 1:39 [PATCH v3] arm/mm: Fix refcount leak bugs in cache Liang He
@ 2022-06-22 8:58 ` Krzysztof Kozlowski
0 siblings, 0 replies; 2+ messages in thread
From: Krzysztof Kozlowski @ 2022-06-22 8:58 UTC (permalink / raw)
To: Liang He, linux, rmk+kernel, wangkefeng.wang, ardb, arnd, akpm, rppt
Cc: linux-arm-kernel, linux-kernel
On 19/06/2022 03:39, Liang He wrote:
> 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
>
Before applying the patch please check it carefully. Previous evidence
[1][2] suggests that not it was not even compiled.
[1] https://lore.kernel.org/all/202206221602.odN70SHs-lkp@intel.com/
[2]
https://lore.kernel.org/all/16f9a971.44e5.1817068ee3c.Coremail.windhl@126.com/
Best regards,
Krzysztof
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-06-22 9:01 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-19 1:39 [PATCH v3] arm/mm: Fix refcount leak bugs in cache Liang He
2022-06-22 8:58 ` Krzysztof Kozlowski
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).