linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH V2] clk: renesas: Fix memory leak of 'cpg'
@ 2022-04-13  8:19 Haowen Bai
  2022-04-13  8:41 ` Geert Uytterhoeven
  2022-04-14  9:29 ` Sergey Shtylyov
  0 siblings, 2 replies; 10+ messages in thread
From: Haowen Bai @ 2022-04-13  8:19 UTC (permalink / raw)
  To: Geert Uytterhoeven, Michael Turquette, Stephen Boyd
  Cc: Haowen Bai, linux-renesas-soc, linux-clk, linux-kernel

Fix this issue by freeing the cpg when exiting the function in the
error/normal path.

Signed-off-by: Haowen Bai <baihaowen@meizu.com>
---
V1->V2: free both cpg&clks.

 drivers/clk/renesas/clk-r8a73a4.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/clk/renesas/clk-r8a73a4.c b/drivers/clk/renesas/clk-r8a73a4.c
index cfed11c659d9..5a8d976f49e0 100644
--- a/drivers/clk/renesas/clk-r8a73a4.c
+++ b/drivers/clk/renesas/clk-r8a73a4.c
@@ -215,7 +215,7 @@ static void __init r8a73a4_cpg_clocks_init(struct device_node *np)
 
 	cpg->reg = of_iomap(np, 0);
 	if (WARN_ON(cpg->reg == NULL))
-		return;
+		goto out_free_cpg;
 
 	for (i = 0; i < num_clks; ++i) {
 		const char *name;
@@ -233,6 +233,9 @@ static void __init r8a73a4_cpg_clocks_init(struct device_node *np)
 	}
 
 	of_clk_add_provider(np, of_clk_src_onecell_get, &cpg->data);
+out_free_cpg:
+	kfree(cpg);
+	kfree(clks);
 }
 CLK_OF_DECLARE(r8a73a4_cpg_clks, "renesas,r8a73a4-cpg-clocks",
 	       r8a73a4_cpg_clocks_init);
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 10+ messages in thread
[parent not found: <8dvhtgydaq7tflf8q4rq4fpu.1649846600874@email.android.com>]
* [PATCH V2] clk: renesas: Fix memory leak of 'cpg'
@ 2022-04-13  8:16 Haowen Bai
  0 siblings, 0 replies; 10+ messages in thread
From: Haowen Bai @ 2022-04-13  8:16 UTC (permalink / raw)
  To: Geert Uytterhoeven, Michael Turquette, Stephen Boyd
  Cc: Haowen Bai, linux-renesas-soc, linux-clk, linux-kernel

Fix this issue by freeing the cpg when exiting the function in the
error/normal path.

Signed-off-by: Haowen Bai <baihaowen@meizu.com>
---
V1->V2: free both cpg&clks

 drivers/clk/renesas/clk-r8a73a4.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/clk/renesas/clk-r8a73a4.c b/drivers/clk/renesas/clk-r8a73a4.c
index cfed11c659d9..5a8d976f49e0 100644
--- a/drivers/clk/renesas/clk-r8a73a4.c
+++ b/drivers/clk/renesas/clk-r8a73a4.c
@@ -215,7 +215,7 @@ static void __init r8a73a4_cpg_clocks_init(struct device_node *np)
 
 	cpg->reg = of_iomap(np, 0);
 	if (WARN_ON(cpg->reg == NULL))
-		return;
+		goto out_free_cpg;
 
 	for (i = 0; i < num_clks; ++i) {
 		const char *name;
@@ -233,6 +233,9 @@ static void __init r8a73a4_cpg_clocks_init(struct device_node *np)
 	}
 
 	of_clk_add_provider(np, of_clk_src_onecell_get, &cpg->data);
+out_free_cpg:
+	kfree(cpg);
+	kfree(clks);
 }
 CLK_OF_DECLARE(r8a73a4_cpg_clks, "renesas,r8a73a4-cpg-clocks",
 	       r8a73a4_cpg_clocks_init);
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2022-04-14 18:26 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-13  8:19 [PATCH V2] clk: renesas: Fix memory leak of 'cpg' Haowen Bai
2022-04-13  8:41 ` Geert Uytterhoeven
2022-04-13  9:24   ` baihaowen
2022-04-13 10:39     ` Geert Uytterhoeven
2022-04-14  9:29 ` Sergey Shtylyov
2022-04-14  9:31   ` baihaowen
2022-04-14  9:32   ` Geert Uytterhoeven
2022-04-14 18:26     ` Sergey Shtylyov
     [not found] <8dvhtgydaq7tflf8q4rq4fpu.1649846600874@email.android.com>
2022-04-13 11:23 ` Geert Uytterhoeven
  -- strict thread matches above, loose matches on Subject: below --
2022-04-13  8:16 Haowen Bai

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).