提交 4974259e 编写于 作者: J James Liao 提交者: Stephen Boyd

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: NJames Liao <jamesjj.liao@mediatek.com>
Reviewed-by: NDaniel Kurtz <djkurtz@chromium.org>
Signed-off-by: NStephen Boyd <sboyd@codeaurora.org>
上级 5fd9c05c
......@@ -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);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册