[PATCH] clk: renesas: Fix memory leak of 'cpg'
From: Haowen Bai
Date: Wed Apr 13 2022 - 03:57:22 EST
Fix this issue by freeing the cpg when exiting the function in the
error/normal path.
Signed-off-by: Haowen Bai <baihaowen@xxxxxxxxx>
---
drivers/clk/renesas/clk-r8a7778.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/clk/renesas/clk-r8a7778.c b/drivers/clk/renesas/clk-r8a7778.c
index 3ccc53685bdd..ad2c080402c1 100644
--- a/drivers/clk/renesas/clk-r8a7778.c
+++ b/drivers/clk/renesas/clk-r8a7778.c
@@ -116,7 +116,7 @@ static void __init r8a7778_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;
@@ -136,6 +136,8 @@ static void __init r8a7778_cpg_clocks_init(struct device_node *np)
of_clk_add_provider(np, of_clk_src_onecell_get, &cpg->data);
cpg_mstp_add_clk_domain(np);
+out_free_cpg:
+ kfree(cpg);
}
CLK_OF_DECLARE(r8a7778_cpg_clks, "renesas,r8a7778-cpg-clocks",
--
2.7.4