Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1304261
| From | Daniel Kurtz <djkurtz@chromium.org> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH] clk: mediatek: Fix memory leak on clock init fail |
| Date | 2016-01-08 09:30 +0100 |
| Message-ID | <qOAAO-45F-11@gated-at.bofh.it> (permalink) |
| References | <qOAr8-413-13@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On Fri, Jan 8, 2016 at 4:15 PM, James Liao <jamesjj.liao@mediatek.com> wrote:
> 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>
> ---
> drivers/clk/mediatek/clk-mtk.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/clk/mediatek/clk-mtk.c b/drivers/clk/mediatek/clk-mtk.c
> index cf08db6..3528303 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);
> --
> 1.9.1
>
Back to linux.kernel | Previous | Next — Previous in thread | Find similar | Unroll thread
[PATCH] clk: mediatek: Fix memory leak on clock init fail James Liao <jamesjj.liao@mediatek.com> - 2016-01-08 09:20 +0100 Re: [PATCH] clk: mediatek: Fix memory leak on clock init fail Daniel Kurtz <djkurtz@chromium.org> - 2016-01-08 09:30 +0100
csiph-web