linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] "clocksource/drivers/cadence_ttc: fix memory leak in ttc_setup_clockevent()
@ 2020-11-10  1:15 Yu Kuai
  2020-11-10 10:04 ` Michal Simek
  0 siblings, 1 reply; 9+ messages in thread
From: Yu Kuai @ 2020-11-10  1:15 UTC (permalink / raw)
  To: michal.simek, daniel.lezcano, tglx, soren.brinkmann
  Cc: linux-arm-kernel, linux-kernel, yukuai3, yi.zhang, zhangxiaoxu5

If clk_notifier_register() failed, ttc_setup_clockevent() will return
without freeing 'ttcce', which will leak memory.

Fixes: 70504f311d4b ("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>
---
 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 80e960602030..32b9560ce408 100644
--- a/drivers/clocksource/timer-cadence-ttc.c
+++ b/drivers/clocksource/timer-cadence-ttc.c
@@ -426,6 +426,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.25.4


^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2020-12-03 23:48 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-10  1:15 [PATCH] "clocksource/drivers/cadence_ttc: fix memory leak in ttc_setup_clockevent() Yu Kuai
2020-11-10 10:04 ` Michal Simek
2020-11-10 10:07   ` Michal Simek
2020-11-11  1:16     ` [PATCH V2] clocksource/drivers/cadence_ttc: " Yu Kuai
2020-11-12  9:59       ` Daniel Lezcano
2020-11-16  7:08         ` [PATCH V3] " Yu Kuai
2020-11-16 13:51           ` [PATCH V4] " Yu Kuai
2020-11-17  9:07             ` Daniel Lezcano
2020-12-03 23:47             ` [tip: timers/core] clocksource/drivers/cadence_ttc: Fix " tip-bot2 for Yu Kuai

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).