summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShawn Lin <shawn.lin@rock-chips.com>2016-02-02 11:37:50 +0800
committerSasha Levin <sasha.levin@oracle.com>2016-07-12 08:48:01 -0400
commit35807de76e1c2b7d15eea2f947983fcd043a2db0 (patch)
tree05f8910cd3343a061c88a13d3f14184962455761
parent8810dfe35a3861390b9c2d4ca79537274e1de1ac (diff)
downloadlwn-35807de76e1c2b7d15eea2f947983fcd043a2db0.tar.gz
lwn-35807de76e1c2b7d15eea2f947983fcd043a2db0.zip
clk: rockchip: free memory in error cases when registering clock branches
[ Upstream commit 2467b6745e0ae9c6cdccff24c4cceeb14b1cce3f ] 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> Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
-rw-r--r--drivers/clk/rockchip/clk.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/drivers/clk/rockchip/clk.c b/drivers/clk/rockchip/clk.c
index 880a266f0143..a25261aaf793 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,
if (gate_offset >= 0) {
gate = kzalloc(sizeof(*gate), GFP_KERNEL);
if (!gate)
- return ERR_PTR(-ENOMEM);
+ goto err_gate;
gate->flags = gate_flags;
gate->reg = base + gate_offset;
@@ -82,7 +82,7 @@ static struct clk *rockchip_clk_register_branch(const char *name,
if (div_width > 0) {
div = kzalloc(sizeof(*div), GFP_KERNEL);
if (!div)
- return ERR_PTR(-ENOMEM);
+ goto err_div;
div->flags = div_flags;
div->reg = base + muxdiv_offset;
@@ -100,6 +100,11 @@ static struct clk *rockchip_clk_register_branch(const char *name,
flags);
return clk;
+err_div:
+ kfree(gate);
+err_gate:
+ kfree(mux);
+ return ERR_PTR(-ENOMEM);
}
static struct clk *rockchip_clk_register_frac_branch(const char *name,