* [PATCH] clocksource: cadence_ttc: fix memory leak in ttc_setup_clockevent
@ 2019-03-09 13:19 Yue Haibing
2019-03-09 14:24 ` Daniel Lezcano
0 siblings, 1 reply; 4+ messages in thread
From: Yue Haibing @ 2019-03-09 13:19 UTC (permalink / raw)
To: michal.simek, daniel.lezcano, tglx
Cc: linux-kernel, linux-arm-kernel, YueHaibing
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;
}
--
2.7.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] clocksource: cadence_ttc: fix memory leak in ttc_setup_clockevent
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
2019-03-13 13:55 ` Michal Simek
0 siblings, 2 replies; 4+ messages in thread
From: Daniel Lezcano @ 2019-03-09 14:24 UTC (permalink / raw)
To: Yue Haibing, michal.simek, tglx; +Cc: linux-kernel, linux-arm-kernel
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
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;
> }
>
>
--
<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
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] clocksource: cadence_ttc: fix memory leak in ttc_setup_clockevent
2019-03-09 14:24 ` Daniel Lezcano
@ 2019-03-11 15:47 ` YueHaibing
2019-03-13 13:55 ` Michal Simek
1 sibling, 0 replies; 4+ messages in thread
From: YueHaibing @ 2019-03-11 15:47 UTC (permalink / raw)
To: Daniel Lezcano, michal.simek, tglx; +Cc: linux-kernel, linux-arm-kernel
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;
>> }
>>
>>
>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] clocksource: cadence_ttc: fix memory leak in ttc_setup_clockevent
2019-03-09 14:24 ` Daniel Lezcano
2019-03-11 15:47 ` YueHaibing
@ 2019-03-13 13:55 ` Michal Simek
1 sibling, 0 replies; 4+ messages in thread
From: Michal Simek @ 2019-03-13 13:55 UTC (permalink / raw)
To: Daniel Lezcano, Yue Haibing, michal.simek, tglx
Cc: linux-kernel, linux-arm-kernel
On 09. 03. 19 15: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
I have put a record to Xilinx database to take a look at it when we have
time.
Thanks,
Michal
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-03-13 13:56 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
2019-03-13 13:55 ` Michal Simek
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).