From: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Andrey Smirnov <andrew.smirnov@gmail.com>
Subject: [PATCH] clk: imx: cpu: don't store the address of a function parameter
Date: Thu, 3 Aug 2017 21:14:38 +0200 [thread overview]
Message-ID: <20170803191438.24473-1-u.kleine-koenig@pengutronix.de> (raw)
The function imx_clk_cpu takes a const char *parent_name as second
paramter. The implementation introduced in commit 9a89ed9d281e then
uses the address of this function parameter to assign clk.parent_names.
This is an address on the stack that is saved in the clk tree and of
course this is easily overwritten by later execution paths of barebox.
Without this fix the clk_dump command reproducibly crashes on i.MX7
(which is the only SoC that makes use of imx_clk_cpu()).
Fixes: 9a89ed9d281e ("clk: imx: Add clk-cpu support")
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
drivers/clk/imx/clk-cpu.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/drivers/clk/imx/clk-cpu.c b/drivers/clk/imx/clk-cpu.c
index bd1749fd870b..5ac0ed178932 100644
--- a/drivers/clk/imx/clk-cpu.c
+++ b/drivers/clk/imx/clk-cpu.c
@@ -82,14 +82,22 @@ static const struct clk_ops clk_cpu_ops = {
.set_rate = clk_cpu_set_rate,
};
+struct imx_clk_cpu {
+ struct clk_cpu cpu;
+ const char *parent_name;
+};
+
struct clk *imx_clk_cpu(const char *name, const char *parent_name,
struct clk *div, struct clk *mux, struct clk *pll,
struct clk *step)
{
+ struct imx_clk_cpu *icpu;
struct clk_cpu *cpu;
int ret;
- cpu = xzalloc(sizeof(*cpu));
+ icpu = xzalloc(sizeof(*icpu));
+ icpu->parent_name = parent_name;
+ cpu = &icpu->cpu;
cpu->div = div;
cpu->mux = mux;
@@ -99,7 +107,7 @@ struct clk *imx_clk_cpu(const char *name, const char *parent_name,
cpu->clk.name = name;
cpu->clk.ops = &clk_cpu_ops;
cpu->clk.flags = 0;
- cpu->clk.parent_names = &parent_name;
+ cpu->clk.parent_names = &icpu->parent_name;
cpu->clk.num_parents = 1;
ret = clk_register(&cpu->clk);
--
2.11.0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
reply other threads:[~2017-08-03 19:15 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20170803191438.24473-1-u.kleine-koenig@pengutronix.de \
--to=u.kleine-koenig@pengutronix.de \
--cc=andrew.smirnov@gmail.com \
--cc=barebox@lists.infradead.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