lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAGS+omCXK4mFBz1HoDUMCPHKa5cqa4DOkbjBuratcps6nBLfig@mail.gmail.com>
Date:	Fri, 8 Jan 2016 16:21:18 +0800
From:	Daniel Kurtz <djkurtz@...omium.org>
To:	James Liao <jamesjj.liao@...iatek.com>
Cc:	Matthias Brugger <matthias.bgg@...il.com>,
	Mike Turquette <mturquette@...libre.com>,
	Stephen Boyd <sboyd@...eaurora.org>,
	Sascha Hauer <kernel@...gutronix.de>,
	srv_heupstream <srv_heupstream@...iatek.com>,
	"linux-arm-kernel@...ts.infradead.org" 
	<linux-arm-kernel@...ts.infradead.org>,
	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
	"moderated list:ARM/Mediatek SoC support" 
	<linux-mediatek@...ts.infradead.org>, linux-clk@...r.kernel.org
Subject: Re: [PATCH] clk: mediatek: Fix memory leak on clock init fail

On Fri, Jan 8, 2016 at 4:15 PM, James Liao <jamesjj.liao@...iatek.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@...iatek.com>

Reviewed-by: Daniel Kurtz <djkurtz@...omium.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
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ