From: sashiko-bot@kernel.org
To: Johnny.Fan <johnny.fan@cixtech.com>
Cc: "Alexandre Belloni" <alexandre.belloni@bootlin.com>,
linux-rtc@vger.kernel.org
Subject: Re: [PATCH v3] rtc: efi: restore alarm support with runtime capability probe
Date: Mon, 31 Aug 2026 17:47:05 +0000 [thread overview]
Message-ID: <20260831174705.689DB1F00A3D@smtp.kernel.org> (raw)
In-Reply-To: <20260831140014.839222-1-johnny.fan@cixtech.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Zero-initializing `eft` causes `efi_read_alarm()` to always fail with `-EIO` for disabled alarms, completely breaking userspace reads.
--
commit b695e617f63e29889d5f34a76788ecbfdea7f619
Author: Johnny.Fan <Johnny.Fan@cixtech.com>
rtc: efi: restore alarm support with runtime capability probe
This commit restores EFI RTC alarm functionality removed in a previous commit.
It adds a capability probe at ->probe() time to check if GetWakeupTime()
actually works before exposing the alarm feature to the OS.
> diff --git a/drivers/rtc/rtc-efi.c b/drivers/rtc/rtc-efi.c
> index b4f44999ef0f4..a8c18ebc55996 100644
> --- a/drivers/rtc/rtc-efi.c
> +++ b/drivers/rtc/rtc-efi.c
[ ... ]
> @@ -112,6 +113,35 @@ convert_from_efi_time(efi_time_t *eft, struct rtc_time *wtime)
> return true;
> }
>
> +static int efi_read_alarm(struct device *dev, struct rtc_wkalrm *wkalrm)
> +{
> + efi_time_t eft;
> + efi_status_t status;
> +
> + memset(&eft, 0, sizeof(eft));
> + status = efi.get_wakeup_time((efi_bool_t *)&wkalrm->enabled,
> + (efi_bool_t *)&wkalrm->pending, &eft);
> + if (status != EFI_SUCCESS)
> + return -EINVAL;
> +
> + if (!convert_from_efi_time(&eft, &wkalrm->time))
> + return -EIO;
[Severity: High]
Does this zero-initialization cause efi_read_alarm() to fail unconditionally
with -EIO for disabled alarms?
When the alarm is disabled, firmware can return EFI_SUCCESS but leave the
eft structure untouched, as allowed by the UEFI spec. Because this patch adds
memset(&eft, 0, sizeof(eft)), eft.day and eft.month will remain 0.
Looking at convert_from_efi_time(), there is a preexisting validation check:
drivers/rtc/rtc-efi.c:convert_from_efi_time() {
...
if (!eft->day || eft->day > 31)
return false;
...
}
This check strictly rejects 0 as a valid day, nullifying the attempt to use
an all-zero structure to bypass validation. As a result, reading a disabled
RTC alarm will fail with -EIO rather than correctly reporting the disabled
state, breaking userspace tools like hwclock or sysfs reads that expect to
read the alarm status without a hard I/O error.
> +
> + return rtc_valid_tm(&wkalrm->time);
> +}
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260831140014.839222-1-johnny.fan@cixtech.com?part=1
prev parent reply other threads:[~2026-08-31 17:47 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-28 3:15 [PATCH] rtc: efi: restore alarm support with runtime capability probe Johnny.Fan
2026-08-28 3:32 ` sashiko-bot
2026-08-28 7:26 ` Ard Biesheuvel
2026-08-28 8:23 ` Johnny Fan
2026-08-28 8:32 ` Johnny Fan
2026-08-28 10:13 ` Ard Biesheuvel
2026-08-28 12:48 ` Alexandre Belloni
2026-08-31 1:10 ` Feng Tang
2026-08-31 11:38 ` [PATCH v2] " Johnny.Fan
2026-08-31 11:56 ` sashiko-bot
2026-08-31 13:34 ` Ard Biesheuvel
2026-08-31 14:00 ` [PATCH v3] " Johnny.Fan
2026-08-31 17:47 ` sashiko-bot [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=20260831174705.689DB1F00A3D@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=alexandre.belloni@bootlin.com \
--cc=johnny.fan@cixtech.com \
--cc=linux-rtc@vger.kernel.org \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox