From: Markus Elfring <Markus.Elfring@web.de>
To: vulab@iscas.ac.cn, linux-arm-kernel@lists.infradead.org
Cc: LKML <linux-kernel@vger.kernel.org>,
Daniel Lezcano <daniel.lezcano@linaro.org>,
Michal Simek <michal.simek@amd.com>,
Thomas Gleixner <tglx@linutronix.de>
Subject: Re: [PATCH] clocksource: timer-cadence-ttc: Fix resource leaks in error paths
Date: Wed, 26 Nov 2025 11:34:33 +0100 [thread overview]
Message-ID: <25f4192a-f518-4b26-9757-e23585177dbf@web.de> (raw)
In-Reply-To: <20251126074559.1709-1-vulab@iscas.ac.cn>
> 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
prev parent reply other threads:[~2025-11-26 10:35 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-26 7:45 Haotian Zhang
2025-11-26 10:34 ` Markus Elfring [this message]
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=25f4192a-f518-4b26-9757-e23585177dbf@web.de \
--to=markus.elfring@web.de \
--cc=daniel.lezcano@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=michal.simek@amd.com \
--cc=tglx@linutronix.de \
--cc=vulab@iscas.ac.cn \
/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
all inboxes | Powered by JetHome®