linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Daniel Lezcano <daniel.lezcano@linaro.org>
To: Navid Emamdoost <navid.emamdoost@gmail.com>,
	Michal Simek <michal.simek@xilinx.com>
Cc: Navid Emamdoost <emamd001@umn.edu>,
	Thomas Gleixner <tglx@linutronix.de>,
	linux-arm-kernel@lists.infradead.org,
	LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] clocksource/drivers: Fix error handling in ttc_setup_clocksource
Date: Mon, 16 Dec 2019 14:41:10 +0100	[thread overview]
Message-ID: <26da3a6b-60f3-d09b-6eff-7a3db8234d64@linaro.org> (raw)
In-Reply-To: <CAEkB2ETvi=Zryh+3UnSddrprnB+MzSObAbsms+6LHHLuiRwZjw@mail.gmail.com>


Hi Navid,

On 14/12/2019 23:54, Navid Emamdoost wrote:
> Would you review this patch, please?

please fix the version number, send without in-reply-to.

Do the same for the other patch:

clocksource/drivers: Fix memory leak in ttc_setup_clockevent

It is a bit confuse what patch is ok or not.

Thanks

  -- Daniel

> On Tue, Oct 22, 2019 at 11:47 PM Navid Emamdoost
> <navid.emamdoost@gmail.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@gmail.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
>>
> 
> 


-- 
 <http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog


  reply	other threads:[~2019-12-16 13:41 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-21 20:18 [PATCH] clocksource/drivers: Fix memory leak in ttc_setup_clockevent Navid Emamdoost
2019-10-22  8:26 ` Markus Elfring
2019-10-22  8:51   ` Michal Simek
2019-10-23  4:31     ` [PATCH v2] " Navid Emamdoost
2019-10-23  7:32       ` Michal Simek
2019-10-23  8:00       ` Markus Elfring
2019-10-23  4:47     ` [PATCH] clocksource/drivers: Fix error handling in ttc_setup_clocksource Navid Emamdoost
2019-10-23  7:24       ` Markus Elfring
2019-10-23  8:20       ` Markus Elfring
2019-10-23 10:31       ` Markus Elfring
2019-12-14 22:54       ` Navid Emamdoost
2019-12-16 13:41         ` Daniel Lezcano [this message]
2019-12-17 15:09           ` Michal Simek
2019-10-23  4:50     ` [PATCH] clocksource/drivers: Fix memory leak in ttc_setup_clockevent Navid Emamdoost

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=26da3a6b-60f3-d09b-6eff-7a3db8234d64@linaro.org \
    --to=daniel.lezcano@linaro.org \
    --cc=emamd001@umn.edu \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=michal.simek@xilinx.com \
    --cc=navid.emamdoost@gmail.com \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).