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]
Date:   Mon, 29 Oct 2018 10:23:47 -0700
From:   Stephen Boyd <sboyd@...nel.org>
To:     Yi Wang <wang.yi59@....com.cn>, paul.burton@...s.com
Cc:     mturquette@...libre.com, linux-mips@...ux-mips.org,
        linux-clk@...r.kernel.org, linux-kernel@...r.kernel.org,
        zhong.weidong@....com.cn, Yi Wang <wang.yi59@....com.cn>
Subject: Re: [PATCH v2] clk: boston: fix possible memory leak in clk_boston_setup()

Quoting Yi Wang (2018-10-29 01:31:47)
> 'onecell' is malloced in clk_boston_setup(), but is not freed
> before leaving from the error handling cases.

How did you find this? Visual inspection? Some coccinelle script?

> 
> Signed-off-by: Yi Wang <wang.yi59@....com.cn>
> ---
> v2: fix syntax issue in comment, thanks to  Sergei.
> 
>  drivers/clk/imgtec/clk-boston.c | 11 ++++++++---
>  1 file changed, 8 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/clk/imgtec/clk-boston.c b/drivers/clk/imgtec/clk-boston.c
> index 15af423..f5d54a6 100644
> --- a/drivers/clk/imgtec/clk-boston.c
> +++ b/drivers/clk/imgtec/clk-boston.c
> @@ -73,27 +73,32 @@ static void __init clk_boston_setup(struct device_node *np)
>         hw = clk_hw_register_fixed_rate(NULL, "input", NULL, 0, in_freq);
>         if (IS_ERR(hw)) {
>                 pr_err("failed to register input clock: %ld\n", PTR_ERR(hw));
> -               return;
> +               goto error;
>         }
>         onecell->hws[BOSTON_CLK_INPUT] = hw;
>  
>         hw = clk_hw_register_fixed_rate(NULL, "sys", "input", 0, sys_freq);
>         if (IS_ERR(hw)) {
>                 pr_err("failed to register sys clock: %ld\n", PTR_ERR(hw));
> -               return;
> +               goto error;
>         }
>         onecell->hws[BOSTON_CLK_SYS] = hw;
>  
>         hw = clk_hw_register_fixed_rate(NULL, "cpu", "input", 0, cpu_freq);
>         if (IS_ERR(hw)) {
>                 pr_err("failed to register cpu clock: %ld\n", PTR_ERR(hw));
> -               return;
> +               goto error;
>         }
>         onecell->hws[BOSTON_CLK_CPU] = hw;
>  
>         err = of_clk_add_hw_provider(np, of_clk_hw_onecell_get, onecell);
>         if (err)
>                 pr_err("failed to add DT provider: %d\n", err);
> +
> +       return;
> +
> +error:
> +       kfree(onecell);

Ok, sure. But then clks are still left registered on failure?

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ