diff options
author | Shawn Lin <shawn.lin@rock-chips.com> | 2016-02-01 22:37:50 -0500 |
---|---|---|
committer | Heiko Stuebner <heiko@sntech.de> | 2016-02-02 16:09:50 -0500 |
commit | 2467b6745e0ae9c6cdccff24c4cceeb14b1cce3f (patch) | |
tree | ab6f86071b045950e3272f4a83ffc8aa8207f193 | |
parent | 89aa027e6019d6e631a6c18c877e01f890a1800f (diff) |
clk: rockchip: free memory in error cases when registering clock branches
Add free memeory if rockchip_clk_register_branch fails.
Fixes: a245fecbb806 ("clk: rockchip: add basic infrastructure...")
Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
Signed-off-by: Heiko Stuebner <heiko@sntech.de>
-rw-r--r-- | drivers/clk/rockchip/clk.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/drivers/clk/rockchip/clk.c b/drivers/clk/rockchip/clk.c index d9a0b5d4d47f..62fbe2c6eaaf 100644 --- a/drivers/clk/rockchip/clk.c +++ b/drivers/clk/rockchip/clk.c | |||
@@ -70,7 +70,7 @@ static struct clk *rockchip_clk_register_branch(const char *name, | |||
70 | if (gate_offset >= 0) { | 70 | if (gate_offset >= 0) { |
71 | gate = kzalloc(sizeof(*gate), GFP_KERNEL); | 71 | gate = kzalloc(sizeof(*gate), GFP_KERNEL); |
72 | if (!gate) | 72 | if (!gate) |
73 | return ERR_PTR(-ENOMEM); | 73 | goto err_gate; |
74 | 74 | ||
75 | gate->flags = gate_flags; | 75 | gate->flags = gate_flags; |
76 | gate->reg = base + gate_offset; | 76 | gate->reg = base + gate_offset; |
@@ -82,7 +82,7 @@ static struct clk *rockchip_clk_register_branch(const char *name, | |||
82 | if (div_width > 0) { | 82 | if (div_width > 0) { |
83 | div = kzalloc(sizeof(*div), GFP_KERNEL); | 83 | div = kzalloc(sizeof(*div), GFP_KERNEL); |
84 | if (!div) | 84 | if (!div) |
85 | return ERR_PTR(-ENOMEM); | 85 | goto err_div; |
86 | 86 | ||
87 | div->flags = div_flags; | 87 | div->flags = div_flags; |
88 | div->reg = base + muxdiv_offset; | 88 | div->reg = base + muxdiv_offset; |
@@ -100,6 +100,11 @@ static struct clk *rockchip_clk_register_branch(const char *name, | |||
100 | flags); | 100 | flags); |
101 | 101 | ||
102 | return clk; | 102 | return clk; |
103 | err_div: | ||
104 | kfree(gate); | ||
105 | err_gate: | ||
106 | kfree(mux); | ||
107 | return ERR_PTR(-ENOMEM); | ||
103 | } | 108 | } |
104 | 109 | ||
105 | struct rockchip_clk_frac { | 110 | struct rockchip_clk_frac { |