linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Haowen Bai <baihaowen@meizu.com>
To: Geert Uytterhoeven <geert+renesas@glider.be>,
	Michael Turquette <mturquette@baylibre.com>,
	Stephen Boyd <sboyd@kernel.org>
Cc: Haowen Bai <baihaowen@meizu.com>,
	<linux-renesas-soc@vger.kernel.org>, <linux-clk@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>
Subject: [PATCH V2] clk: renesas: Fix memory leak of 'cpg'
Date: Wed, 13 Apr 2022 16:19:13 +0800	[thread overview]
Message-ID: <1649837953-10984-1-git-send-email-baihaowen@meizu.com> (raw)

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


             reply	other threads:[~2022-04-13  8:19 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-13  8:19 Haowen Bai [this message]
2022-04-13  8:41 ` [PATCH V2] clk: renesas: Fix memory leak of 'cpg' 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

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=1649837953-10984-1-git-send-email-baihaowen@meizu.com \
    --to=baihaowen@meizu.com \
    --cc=geert+renesas@glider.be \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=mturquette@baylibre.com \
    --cc=sboyd@kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).