1 From 9dc8189536f4c59bb7ad8c736021cefc1488bf74 Mon Sep 17 00:00:00 2001
2 From: "Victor N. Ramos Mello" <victornrm@gmail.com>
3 Date: Fri, 18 Oct 2013 20:27:51 -0300
4 Subject: [PATCH] drivers: clk: sunxi: Fix memory leakage in clk-sunxi.c
6 Fix a possible memory leak in sun4i_osc_clk_setup().
7 Moved clock-frequency check to save superfluous allocation.
9 Signed-off-by: Victor N. Ramos Mello <victornrm@gmail.com>
10 Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
12 drivers/clk/sunxi/clk-sunxi.c | 28 +++++++++++++++++-----------
13 1 file changed, 17 insertions(+), 11 deletions(-)
15 --- a/drivers/clk/sunxi/clk-sunxi.c
16 +++ b/drivers/clk/sunxi/clk-sunxi.c
17 @@ -37,18 +37,16 @@ static void __init sun4i_osc_clk_setup(s
18 const char *clk_name = node->name;
21 + if (of_property_read_u32(node, "clock-frequency", &rate))
24 /* allocate fixed-rate and gate clock structs */
25 fixed = kzalloc(sizeof(struct clk_fixed_rate), GFP_KERNEL);
28 gate = kzalloc(sizeof(struct clk_gate), GFP_KERNEL);
34 - if (of_property_read_u32(node, "clock-frequency", &rate))
37 + goto err_free_fixed;
39 /* set up gate and fixed rate properties */
40 gate->reg = of_iomap(node, 0);
41 @@ -63,10 +61,18 @@ static void __init sun4i_osc_clk_setup(s
42 &gate->hw, &clk_gate_ops,
46 - of_clk_add_provider(node, of_clk_src_simple_get, clk);
47 - clk_register_clkdev(clk, clk_name, NULL);
52 + of_clk_add_provider(node, of_clk_src_simple_get, clk);
53 + clk_register_clkdev(clk, clk_name, NULL);
62 CLK_OF_DECLARE(sun4i_osc, "allwinner,sun4i-osc-clk", sun4i_osc_clk_setup);