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 diff --git a/drivers/clk/sunxi/clk-sunxi.c b/drivers/clk/sunxi/clk-sunxi.c
16 index 8fc1375..492ef0e 100644
17 --- a/drivers/clk/sunxi/clk-sunxi.c
18 +++ b/drivers/clk/sunxi/clk-sunxi.c
19 @@ -37,18 +37,16 @@ static void __init sun4i_osc_clk_setup(struct device_node *node)
20 const char *clk_name = node->name;
23 + if (of_property_read_u32(node, "clock-frequency", &rate))
26 /* allocate fixed-rate and gate clock structs */
27 fixed = kzalloc(sizeof(struct clk_fixed_rate), GFP_KERNEL);
30 gate = kzalloc(sizeof(struct clk_gate), GFP_KERNEL);
36 - if (of_property_read_u32(node, "clock-frequency", &rate))
39 + goto err_free_fixed;
41 /* set up gate and fixed rate properties */
42 gate->reg = of_iomap(node, 0);
43 @@ -63,10 +61,18 @@ static void __init sun4i_osc_clk_setup(struct device_node *node)
44 &gate->hw, &clk_gate_ops,
48 - of_clk_add_provider(node, of_clk_src_simple_get, clk);
49 - clk_register_clkdev(clk, clk_name, NULL);
54 + of_clk_add_provider(node, of_clk_src_simple_get, clk);
55 + clk_register_clkdev(clk, clk_name, NULL);
64 CLK_OF_DECLARE(sun4i_osc, "allwinner,sun4i-osc-clk", sun4i_osc_clk_setup);