linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: YueHaibing <yuehaibing@huawei.com>
To: Daniel Lezcano <daniel.lezcano@linaro.org>,
	<michal.simek@xilinx.com>, <tglx@linutronix.de>
Cc: <linux-kernel@vger.kernel.org>, <linux-arm-kernel@lists.infradead.org>
Subject: Re: [PATCH] clocksource: cadence_ttc: fix memory leak in ttc_setup_clockevent
Date: Mon, 11 Mar 2019 23:47:08 +0800	[thread overview]
Message-ID: <e0eaa44c-4997-5fd8-8418-ac02922bffcd@huawei.com> (raw)
In-Reply-To: <b9831ea9-3230-6f63-8c73-b3b2cd28c59f@linaro.org>


On 2019/3/9 22:24, Daniel Lezcano wrote:
> 
> Hi Yue,
> 
> I appreciate the fix but usually we add a rollback for all the
> operations done in the init function.
> 
> Please, migrate the init function to the timer-of API, so the rollback
> will be automatically handled.
> 
> Example here:
> 
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/clocksource/timer-sprd.c#n197

It seems complicated for me,

ttc_setup_clocksource and ttc_setup_clockevent use a different of_clk,
hard to use timer_of_init to do a initialization.

I'm not familiar with this. Maybe someone else can do this?

> 
> On 09/03/2019 14:19, Yue Haibing wrote:
>> From: YueHaibing <yuehaibing@huawei.com>
>>
>> Add the missing kfree() in ttc_setup_clockevent() to free the
>> mem before error return.
>>
>> Fixes: 70504f311d4b ("clocksource/drivers/cadence_ttc: Convert init function to return error")
>> Signed-off-by: YueHaibing <yuehaibing@huawei.com>
>> ---
>>  drivers/clocksource/timer-cadence-ttc.c | 1 +
>>  1 file changed, 1 insertion(+)
>>
>> diff --git a/drivers/clocksource/timer-cadence-ttc.c b/drivers/clocksource/timer-cadence-ttc.c
>> index b334029..b664af8 100644
>> --- a/drivers/clocksource/timer-cadence-ttc.c
>> +++ b/drivers/clocksource/timer-cadence-ttc.c
>> @@ -432,6 +432,7 @@ static int __init ttc_setup_clockevent(struct clk *clk,
>>  				    &ttcce->ttc.clk_rate_change_nb);
>>  	if (err) {
>>  		pr_warn("Unable to register clock notifier.\n");
>> +		kfree(ttcce);
>>  		return err;
>>  	}
>>  
>>
> 
> 


  reply	other threads:[~2019-03-11 15:47 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-09 13:19 [PATCH] clocksource: cadence_ttc: fix memory leak in ttc_setup_clockevent Yue Haibing
2019-03-09 14:24 ` Daniel Lezcano
2019-03-11 15:47   ` YueHaibing [this message]
2019-03-13 13:55   ` Michal Simek

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=e0eaa44c-4997-5fd8-8418-ac02922bffcd@huawei.com \
    --to=yuehaibing@huawei.com \
    --cc=daniel.lezcano@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=michal.simek@xilinx.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).