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] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAEkB2ETvi=Zryh+3UnSddrprnB+MzSObAbsms+6LHHLuiRwZjw@mail.gmail.com>
Date:   Sat, 14 Dec 2019 16:54:41 -0600
From:   Navid Emamdoost <navid.emamdoost@...il.com>
To:     Michal Simek <michal.simek@...inx.com>
Cc:     Navid Emamdoost <emamd001@....edu>,
        Daniel Lezcano <daniel.lezcano@...aro.org>,
        Thomas Gleixner <tglx@...utronix.de>,
        linux-arm-kernel@...ts.infradead.org,
        LKML <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] clocksource/drivers: Fix error handling in ttc_setup_clocksource

Would you review this patch, please?

On Tue, Oct 22, 2019 at 11:47 PM Navid Emamdoost
<navid.emamdoost@...il.com> wrote:
>
> In the implementation of ttc_setup_clocksource() when
> clk_notifier_register() fails the execution should go to error handling.
> Additionally, to avoid memory leak the allocated memory for ttccs should
> be released, too. So, goto error handling to release the memory and
> return.
>
> Fixes: e932900a3279 ("arm: zynq: Use standard timer binding")
> Signed-off-by: Navid Emamdoost <navid.emamdoost@...il.com>
> ---
>  drivers/clocksource/timer-cadence-ttc.c | 20 +++++++++++---------
>  1 file changed, 11 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/clocksource/timer-cadence-ttc.c b/drivers/clocksource/timer-cadence-ttc.c
> index 88fe2e9ba9a3..035e16bc17d3 100644
> --- a/drivers/clocksource/timer-cadence-ttc.c
> +++ b/drivers/clocksource/timer-cadence-ttc.c
> @@ -328,10 +328,8 @@ static int __init ttc_setup_clocksource(struct clk *clk, void __iomem *base,
>         ttccs->ttc.clk = clk;
>
>         err = clk_prepare_enable(ttccs->ttc.clk);
> -       if (err) {
> -               kfree(ttccs);
> -               return err;
> -       }
> +       if (err)
> +               goto release_ttccs;
>
>         ttccs->ttc.freq = clk_get_rate(ttccs->ttc.clk);
>
> @@ -341,8 +339,10 @@ static int __init ttc_setup_clocksource(struct clk *clk, void __iomem *base,
>
>         err = clk_notifier_register(ttccs->ttc.clk,
>                                     &ttccs->ttc.clk_rate_change_nb);
> -       if (err)
> +       if (err) {
>                 pr_warn("Unable to register clock notifier.\n");
> +               goto release_ttccs;
> +       }
>
>         ttccs->ttc.base_addr = base;
>         ttccs->cs.name = "ttc_clocksource";
> @@ -363,16 +363,18 @@ static int __init ttc_setup_clocksource(struct clk *clk, void __iomem *base,
>                      ttccs->ttc.base_addr + TTC_CNT_CNTRL_OFFSET);
>
>         err = clocksource_register_hz(&ttccs->cs, ttccs->ttc.freq / PRESCALE);
> -       if (err) {
> -               kfree(ttccs);
> -               return err;
> -       }
> +       if (err)
> +               goto release_ttccs;
>
>         ttc_sched_clock_val_reg = base + TTC_COUNT_VAL_OFFSET;
>         sched_clock_register(ttc_sched_clock_read, timer_width,
>                              ttccs->ttc.freq / PRESCALE);
>
>         return 0;
> +
> +release_ttccs:
> +       kfree(ttccs);
> +       return err;
>  }
>
>  static int ttc_rate_change_clockevent_cb(struct notifier_block *nb,
> --
> 2.17.1
>


-- 
Navid.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ