summaryrefslogtreecommitdiffstats
path: root/drivers/clk
diff options
context:
space:
mode:
authorUwe Kleine-König <u.kleine-koenig@pengutronix.de>2017-08-03 21:14:38 +0200
committerLucas Stach <l.stach@pengutronix.de>2017-08-15 15:12:49 +0200
commitb6fcd26f6d90fb248dde024b60fd6a17abe63f33 (patch)
tree056ba2298b27ee7e43d47168f1957510b459cb92 /drivers/clk
parent7597d8e33289bacf57908552b12896062a8ddd4d (diff)
downloadbarebox-b6fcd26f6d90fb248dde024b60fd6a17abe63f33.tar.gz
barebox-b6fcd26f6d90fb248dde024b60fd6a17abe63f33.tar.xz
clk: imx: cpu: don't store the address of a function parameter
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> Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
Diffstat (limited to 'drivers/clk')
-rw-r--r--drivers/clk/imx/clk-cpu.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/drivers/clk/imx/clk-cpu.c b/drivers/clk/imx/clk-cpu.c
index bd1749fd87..5ac0ed1789 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);