From: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
To: mturquette@baylibre.com, sboyd@kernel.org,
gregory.clement@bootlin.com, thomas.petazzoni@free-electrons.com
Cc: linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org,
kernel-janitors@vger.kernel.org,
Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Subject: [PATCH 2/4] clk: mvebu: Fix a another memory leak in an error handling path
Date: Fri, 23 Apr 2021 08:25:10 +0200 [thread overview]
Message-ID: <5f1ba3fb1950a2743ec8c4baa4b4925f134c0f28.1619157996.git.christophe.jaillet@wanadoo.fr> (raw)
In-Reply-To: <cover.1619157996.git.christophe.jaillet@wanadoo.fr>
If we exit the for_each_of_cpu_node loop early, the reference on the
current node must be decremented, otherwise there is a leak.
Fixes: ab8ba01b3fe5 ("clk: mvebu: add armada-370-xp CPU specific clocks")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
drivers/clk/mvebu/clk-cpu.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/drivers/clk/mvebu/clk-cpu.c b/drivers/clk/mvebu/clk-cpu.c
index a11d7273fcc7..9a5c2aec6ec2 100644
--- a/drivers/clk/mvebu/clk-cpu.c
+++ b/drivers/clk/mvebu/clk-cpu.c
@@ -199,11 +199,14 @@ static void __init of_cpu_clk_setup(struct device_node *node)
int cpu, err;
err = of_property_read_u32(dn, "reg", &cpu);
- if (WARN_ON(err))
+ if (WARN_ON(err)) {
+ of_node_put(dn);
goto bail_out;
+ }
clk_name = kasprintf(GFP_KERNEL, "cpu%d", cpu);
if (WARN_ON(!clk_name)) {
+ of_node_put(dn);
goto bail_out;
}
@@ -222,8 +225,10 @@ static void __init of_cpu_clk_setup(struct device_node *node)
init.num_parents = 1;
clk = clk_register(NULL, &cpuclk[cpu].hw);
- if (WARN_ON(IS_ERR(clk)))
+ if (WARN_ON(IS_ERR(clk))) {
+ of_node_put(dn);
goto bail_out;
+ }
clks[cpu] = clk;
}
clk_data.clk_num = MAX_CPU;
--
2.27.0
next prev parent reply other threads:[~2021-04-23 6:25 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-23 6:24 [PATCH 0/4] clk: mvebu: Fix some error handling paths + do some clean-up Christophe JAILLET
2021-04-23 6:25 ` [PATCH 1/4] clk: mvebu: Fix a memory leak in an error handling path Christophe JAILLET
2021-04-23 11:42 ` AW: " Walter Harms
2021-04-23 12:02 ` Christophe JAILLET
2021-04-23 15:34 ` Walter Harms
2021-04-23 6:25 ` Christophe JAILLET [this message]
2021-04-23 6:25 ` [PATCH 3/4] clk: mvebu: Add a missing space Christophe JAILLET
2021-04-23 6:25 ` [PATCH 4/4] clk: mvebu: Remove an unneeded include Christophe JAILLET
2021-04-23 7:27 ` [PATCH 0/4] clk: mvebu: Fix some error handling paths + do some clean-up Thomas Petazzoni
2021-04-23 8:49 ` Christophe JAILLET
2021-05-22 6:51 ` Christophe JAILLET
2021-05-22 7:17 ` Marion & Christophe JAILLET
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=5f1ba3fb1950a2743ec8c4baa4b4925f134c0f28.1619157996.git.christophe.jaillet@wanadoo.fr \
--to=christophe.jaillet@wanadoo.fr \
--cc=gregory.clement@bootlin.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-clk@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mturquette@baylibre.com \
--cc=sboyd@kernel.org \
--cc=thomas.petazzoni@free-electrons.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 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).