Linux RTC
 help / color / mirror / Atom feed
* [PATCH] rtc: interface: Alarm race handling should not discard preceding error
@ 2025-11-25 17:35 Anthony Pighin (Nokia)
  2025-12-16 10:51 ` Thorsten Leemhuis
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Anthony Pighin (Nokia) @ 2025-11-25 17:35 UTC (permalink / raw)
  To: linux-rtc@vger.kernel.org; +Cc: alexandre.belloni@bootlin.com

Commit 795cda8338ea ("rtc: interface: Fix long-standing race when setting
alarm") should not discard any errors from the preceding validations.

Prior to that commit, if the alarm feature was disabled, or the
set_alarm failed, a meaningful error code would be returned to the
caller for further action.

After, more often than not, the __rtc_read_time will cause a success
return code instead, misleading the caller.

An example of this is when timer_enqueue is called for a rtc-abx080x
device. Since that driver does not clear the alarm feature bit, but
instead relies on the set_alarm operation to return invalid, the discard
of the return code causes very different behaviour; i.e.
    hwclock: select() to /dev/rtc0 to wait for clock tick timed out

Fixes: 795cda8338ea ("rtc: interface: Fix long-standing race when setting alarm")
Signed-off-by: Anthony Pighin <anthony.pighin@nokia.com>
---
 drivers/rtc/interface.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/rtc/interface.c b/drivers/rtc/interface.c
index b8b298efd9a9..1906f4884a83 100644
--- a/drivers/rtc/interface.c
+++ b/drivers/rtc/interface.c
@@ -457,7 +457,7 @@ static int __rtc_set_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm)
         * are in, we can return -ETIME to signal that the timer has already
         * expired, which is true in both cases.
         */
-       if ((scheduled - now) <= 1) {
+       if (!err && (scheduled - now) <= 1) {
                err = __rtc_read_time(rtc, &tm);
                if (err)
                        return err;
--
2.43.0

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

end of thread, other threads:[~2026-01-19 23:08 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-25 17:35 [PATCH] rtc: interface: Alarm race handling should not discard preceding error Anthony Pighin (Nokia)
2025-12-16 10:51 ` Thorsten Leemhuis
2025-12-16 15:09   ` Nick Bowler
2026-01-09 12:18     ` Thorsten Leemhuis
2026-01-09 12:54       ` Esben Haabendal
2026-01-09 13:04         ` Thorsten Leemhuis
2026-01-09 12:50 ` Esben Haabendal
2026-01-19 23:08 ` Alexandre Belloni

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox