mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-08-27 19:29:37 +00:00
clocksource/drivers/cadence_ttc: Fix memory leak in ttc_setup_clockevent()
[ Upstream commiteee422c46e
] If clk_notifier_register() failed, ttc_setup_clockevent() will return without freeing 'ttcce', which will leak memory. Fixes:70504f311d
("clocksource/drivers/cadence_ttc: Convert init function to return error") Reported-by: Hulk Robot <hulkci@huawei.com> Signed-off-by: Yu Kuai <yukuai3@huawei.com> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org> Link: https://lore.kernel.org/r/20201116135123.2164033-1-yukuai3@huawei.com Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
742d5de6c2
commit
d903b80e1a
1 changed files with 9 additions and 9 deletions
|
@ -411,10 +411,8 @@ static int __init ttc_setup_clockevent(struct clk *clk,
|
|||
ttcce->ttc.clk = clk;
|
||||
|
||||
err = clk_prepare_enable(ttcce->ttc.clk);
|
||||
if (err) {
|
||||
kfree(ttcce);
|
||||
return err;
|
||||
}
|
||||
if (err)
|
||||
goto out_kfree;
|
||||
|
||||
ttcce->ttc.clk_rate_change_nb.notifier_call =
|
||||
ttc_rate_change_clockevent_cb;
|
||||
|
@ -424,7 +422,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");
|
||||
return err;
|
||||
goto out_kfree;
|
||||
}
|
||||
|
||||
ttcce->ttc.freq = clk_get_rate(ttcce->ttc.clk);
|
||||
|
@ -453,15 +451,17 @@ static int __init ttc_setup_clockevent(struct clk *clk,
|
|||
|
||||
err = request_irq(irq, ttc_clock_event_interrupt,
|
||||
IRQF_TIMER, ttcce->ce.name, ttcce);
|
||||
if (err) {
|
||||
kfree(ttcce);
|
||||
return err;
|
||||
}
|
||||
if (err)
|
||||
goto out_kfree;
|
||||
|
||||
clockevents_config_and_register(&ttcce->ce,
|
||||
ttcce->ttc.freq / PRESCALE, 1, 0xfffe);
|
||||
|
||||
return 0;
|
||||
|
||||
out_kfree:
|
||||
kfree(ttcce);
|
||||
return err;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue