[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <25f4192a-f518-4b26-9757-e23585177dbf@web.de>
Date: Wed, 26 Nov 2025 11:34:33 +0100
From: Markus Elfring <Markus.Elfring@....de>
To: vulab@...as.ac.cn, linux-arm-kernel@...ts.infradead.org
Cc: LKML <linux-kernel@...r.kernel.org>,
Daniel Lezcano <daniel.lezcano@...aro.org>,
Michal Simek <michal.simek@....com>, Thomas Gleixner <tglx@...utronix.de>
Subject: Re: [PATCH] clocksource: timer-cadence-ttc: Fix resource leaks in
error paths
> The ttc_setup_clocksource() and ttc_setup_clockevent() fail to
> unregister the clock notifier in their error paths, potentially
> leading to a resource leak. Additionally, ttc_setup_clocksource()
> leaks the prepared clock reference upon failure.
…
You may occasionally put more than 65 characters into text lines
of such a change description.
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v6.18-rc7#n658
…
> +++ b/drivers/clocksource/timer-cadence-ttc.c
…
> @@ -377,6 +380,10 @@ static int __init ttc_setup_clocksource(struct clk *clk, void __iomem *base,
>
> err = clocksource_register_hz(&ttccs->cs, ttccs->ttc.freq / PRESCALE);
> if (err) {
> + if (notifier_registered)
> + clk_notifier_unregister(ttccs->ttc.clk,
> + &ttccs->ttc.clk_rate_change_nb);
> + clk_disable_unprepare(ttccs->ttc.clk);
> kfree(ttccs);
> return err;
> }
How do you think about to avoid repeated kfree() calls in such a function implementation?
> @@ -465,13 +472,16 @@ static int __init ttc_setup_clockevent(struct clk *clk,
…
> +out_clk_notifier_unregister:
> + clk_notifier_unregister(ttcce->ttc.clk,
> + &ttcce->ttc.clk_rate_change_nb);
…
You may specify this function call in a single line.
Regards,
Markus
Powered by blists - more mailing lists