summaryrefslogtreecommitdiff
path: root/drivers/clk/mediatek
diff options
context:
space:
mode:
authorJames Liao <jamesjj.liao@mediatek.com>2016-01-08 11:15:33 +0300
committerStephen Boyd <sboyd@codeaurora.org>2016-01-30 00:02:51 +0300
commit4974259e18f1fd519d4329babbfefa24852375bb (patch)
treeb722d67e701dda10844e2d5a482f2b6e17cf510a /drivers/clk/mediatek
parent5fd9c05c846db98319e75496612da24435cee208 (diff)
downloadlinux-4974259e18f1fd519d4329babbfefa24852375bb.tar.xz
clk: mediatek: Fix memory leak on clock init fail
mtk_clk_register_composite() may leak memory due to some error handling path don't free all allocated memory. This patch free all pointers that may allocate memory before error return. And it's safe because kfree() can handle NULL pointers. Signed-off-by: James Liao <jamesjj.liao@mediatek.com> Reviewed-by: Daniel Kurtz <djkurtz@chromium.org> Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
Diffstat (limited to 'drivers/clk/mediatek')
-rw-r--r--drivers/clk/mediatek/clk-mtk.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/drivers/clk/mediatek/clk-mtk.c b/drivers/clk/mediatek/clk-mtk.c
index cf08db6c130c..352830369e0e 100644
--- a/drivers/clk/mediatek/clk-mtk.c
+++ b/drivers/clk/mediatek/clk-mtk.c
@@ -209,12 +209,14 @@ struct clk * __init mtk_clk_register_composite(const struct mtk_composite *mc,
mc->flags);
if (IS_ERR(clk)) {
- kfree(gate);
- kfree(mux);
+ ret = PTR_ERR(clk);
+ goto err_out;
}
return clk;
err_out:
+ kfree(div);
+ kfree(gate);
kfree(mux);
return ERR_PTR(ret);