diff options
author | Felipe Pena <felipensp@gmail.com> | 2013-10-07 23:25:44 -0300 |
---|---|---|
committer | Mike Turquette <mturquette@linaro.org> | 2013-10-07 22:43:27 -0700 |
commit | f8fe36f6083a70270a7305f7740b124ff1e8aea7 (patch) | |
tree | 76e9295d55457953e2c9f597649ee664bf4de684 | |
parent | 6cfc229d6f967041b5e1ee56a5bb87a500f31311 (diff) | |
download | blackbird-obmc-linux-f8fe36f6083a70270a7305f7740b124ff1e8aea7.tar.gz blackbird-obmc-linux-f8fe36f6083a70270a7305f7740b124ff1e8aea7.zip |
clk/zynq: Fix possible memory leak
The zynq_clk_register_fclk function can leak memory (fclk_lock) when unable
to alloc memory for fclk_gate_lock
Signed-off-by: Felipe Pena <felipensp@gmail.com>
Acked-by: Sören Brinkmann <soren.brinkmann@xilinx.com>
Signed-off-by: Mike Turquette <mturquette@linaro.org>
-rw-r--r-- | drivers/clk/zynq/clkc.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/drivers/clk/zynq/clkc.c b/drivers/clk/zynq/clkc.c index cc40fe64f2dc..10772aa72e4e 100644 --- a/drivers/clk/zynq/clkc.c +++ b/drivers/clk/zynq/clkc.c @@ -117,13 +117,19 @@ static void __init zynq_clk_register_fclk(enum zynq_clk fclk, goto err; fclk_gate_lock = kmalloc(sizeof(*fclk_gate_lock), GFP_KERNEL); if (!fclk_gate_lock) - goto err; + goto err_fclk_gate_lock; spin_lock_init(fclk_lock); spin_lock_init(fclk_gate_lock); mux_name = kasprintf(GFP_KERNEL, "%s_mux", clk_name); + if (!mux_name) + goto err_mux_name; div0_name = kasprintf(GFP_KERNEL, "%s_div0", clk_name); + if (!div0_name) + goto err_div0_name; div1_name = kasprintf(GFP_KERNEL, "%s_div1", clk_name); + if (!div1_name) + goto err_div1_name; clk = clk_register_mux(NULL, mux_name, parents, 4, CLK_SET_RATE_NO_REPARENT, fclk_ctrl_reg, 4, 2, 0, @@ -147,6 +153,14 @@ static void __init zynq_clk_register_fclk(enum zynq_clk fclk, return; +err_div1_name: + kfree(div0_name); +err_div0_name: + kfree(mux_name); +err_mux_name: + kfree(fclk_gate_lock); +err_fclk_gate_lock: + kfree(fclk_lock); err: clks[fclk] = ERR_PTR(-ENOMEM); } |