From: sashiko-bot@kernel.org
To: "Liu Dalin" <liudalin@kylinsec.com.cn>
Cc: "Alexandre Belloni" <alexandre.belloni@bootlin.com>,
linux-rtc@vger.kernel.org
Subject: Re: [PATCH v1 1/3] rtc: ftrtc010: fix clock resource leak on probe failure
Date: Thu, 27 Aug 2026 06:45:42 +0000 [thread overview]
Message-ID: <20260827064542.80B081F000E9@smtp.kernel.org> (raw)
In-Reply-To: <16D871E1646724FD+20260827063019.3342085-2-liudalin@kylinsec.com.cn>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
Pre-existing issues:
- [High] The interrupt handler unconditionally returns IRQ_HANDLED in a shared IRQ setup, defeating spurious interrupt detection.
- [High] Sequential reads of distinct RTC hardware counters lack software rollover protection, risking time corruption.
--
commit 6944a6b7d4e12941b5612ab5907724e5485e82a6
Author: Liu Dalin <liudalin@kylinsec.com.cn>
rtc: ftrtc010: fix clock resource leak on probe failure
This commit addresses a resource leak in ftrtc010_rtc_probe() that occurs
when devm_rtc_register_device() fails. It captures the return value of the
registration function and jumps to an error handling path. This ensures
that the clocks obtained via clk_prepare_enable() are properly released.
> diff --git a/drivers/rtc/rtc-ftrtc010.c b/drivers/rtc/rtc-ftrtc010.c
> index 02608d3784958..f398d6dc85ae4 100644
> --- a/drivers/rtc/rtc-ftrtc010.c
> +++ b/drivers/rtc/rtc-ftrtc010.c
> @@ -181,7 +181,11 @@ static int ftrtc010_rtc_probe(struct platform_device *pdev)
> if (unlikely(ret))
> goto err_disable_extclk;
>
> - return devm_rtc_register_device(rtc_dev);
> + ret = devm_rtc_register_device(rtc_dev);
> + if (ret)
> + goto err_disable_extclk;
> +
> + return 0;
>
> err_disable_extclk:
> clk_disable_unprepare(rtc->extclk);
[Severity: High]
This is a pre-existing issue, but I noticed the interrupt handler
unconditionally returns IRQ_HANDLED:
drivers/rtc/rtc-ftrtc010.c:ftrtc010_rtc_interrupt() {
return IRQ_HANDLED;
}
Since this interrupt is requested as a shared line just prior to device
registration in ftrtc010_rtc_probe():
ret = devm_request_irq(dev, rtc->rtc_irq, ftrtc010_rtc_interrupt,
IRQF_SHARED, pdev->name, dev);
Could this defeat spurious interrupt detection? If another device on the same
shared IRQ line asserts an interrupt but its handler fails or is not yet
registered, this driver will falsely claim to have handled it. This might
prevent the spurious interrupt detector from disabling the faulty line and
could result in an unrecoverable interrupt storm.
[Severity: High]
This is a pre-existing issue, but does ftrtc010_rtc_read_time() lack software
rollover protection?
drivers/rtc/rtc-ftrtc010.c:ftrtc010_rtc_read_time() {
...
sec = readl(rtc->rtc_base + FTRTC010_RTC_SECOND);
min = readl(rtc->rtc_base + FTRTC010_RTC_MINUTE);
hour = readl(rtc->rtc_base + FTRTC010_RTC_HOUR);
days = readl(rtc->rtc_base + FTRTC010_RTC_DAYS);
...
}
If a hardware tick occurs asynchronously between these distinct readl() calls,
could it mix pre-tick and post-tick units and result in corrupted time? Since
there is no hardware latching indicated and no software retry loop to verify
consistency, an asynchronous tick might cause an incorrect aggregated time to
be passed to the RTC subsystem.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260827063019.3342085-1-liudalin@kylinsec.com.cn?part=1
next prev parent reply other threads:[~2026-08-27 6:45 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-27 1:57 [PATCH] rtc: ftrtc010: fix clock resource leak on probe failure Liu Dalin
2026-08-27 2:10 ` sashiko-bot
2026-08-27 6:30 ` [PATCH v1 0/3] rtc: ftrtc010: fix resource management and integer overflow Liu Dalin
[not found] ` <20260827063019.3342085-1-liudalin@kylinsec.com.cn>
2026-08-27 6:30 ` [PATCH v1 1/3] rtc: ftrtc010: fix clock resource leak on probe failure Liu Dalin
2026-08-27 6:45 ` sashiko-bot [this message]
2026-08-27 8:05 ` liudalin
2026-08-27 6:30 ` [PATCH v1 2/3] rtc: ftrtc010: use devm clock APIs to fix use-after-disable in remove Liu Dalin
2026-08-27 6:43 ` sashiko-bot
2026-08-27 8:06 ` liudalin
2026-08-27 6:30 ` [PATCH v1 3/3] rtc: ftrtc010: fix integer overflow in time calculation Liu Dalin
2026-08-27 6:53 ` sashiko-bot
2026-08-27 8:07 ` liudalin
2026-08-27 8:03 ` [PATCH v2 0/3] rtc: ftrtc010: fix resource management and integer overflow Liu Dalin
2026-09-14 8:38 ` Linus Walleij
2026-09-14 9:12 ` liudalin
2026-10-01 10:00 ` Alexandre Belloni
[not found] ` <20260827080320.3351155-1-liudalin@kylinsec.com.cn>
2026-08-27 8:03 ` [PATCH v2 1/3] rtc: ftrtc010: fix clock resource leak on probe failure Liu Dalin
2026-08-27 8:15 ` sashiko-bot
2026-08-27 8:03 ` [PATCH v2 2/3] rtc: ftrtc010: use devm clock APIs to fix use-after-disable in remove Liu Dalin
2026-08-27 8:15 ` sashiko-bot
2026-08-27 8:03 ` [PATCH v2 3/3] rtc: ftrtc010: fix integer overflow in time calculation Liu Dalin
2026-10-02 10:59 ` Dan Carpenter
2026-08-27 8:17 ` sashiko-bot
2026-10-08 2:10 ` Liu Dalin
2026-09-14 8:35 ` [PATCH] rtc: ftrtc010: fix clock resource leak on probe failure Linus Walleij
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=20260827064542.80B081F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=alexandre.belloni@bootlin.com \
--cc=linux-rtc@vger.kernel.org \
--cc=liudalin@kylinsec.com.cn \
--cc=sashiko-reviews@lists.linux.dev \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.