From: Alexandre Belloni <alexandre.belloni@bootlin.com>
To: Zhaoyang Yu <2426767509@qq.com>
Cc: linux-rtc@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] rtc: spear: check return value of clk_enable in resume
Date: Sun, 12 Apr 2026 23:33:36 +0200 [thread overview]
Message-ID: <20260412213336c5c1e339@mail.local> (raw)
In-Reply-To: <tencent_6BA6C87DB3B5EE61C7A22CADE9F5DBBCC90A@qq.com>
On 01/03/2026 16:19:58+0000, Zhaoyang Yu wrote:
> In spear_rtc_resume(), the return value of clk_enable() is currently
> ignored. If clk_enable() fails, the driver proceeds to call
> spear_rtc_enable_interrupt().
>
> The spear_rtc_enable_interrupt() function performs a readl() on the
> RTC control register (CTRL_REG) as its first operation. Accessing an
> MMIO register of a peripheral without an enabled functional clock is
> unsafe on SPEAr architectures and can lead to a system hang or data
> abort.
>
> Fix this by checking the return value of clk_enable(). If it fails,
> print an error message and return the error code to avoid the unsafe
> register access.
>
> Signed-off-by: Zhaoyang Yu <2426767509@qq.com>
> ---
> drivers/rtc/rtc-spear.c | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/rtc/rtc-spear.c b/drivers/rtc/rtc-spear.c
> index 959acff8faff..9bf7cf264715 100644
> --- a/drivers/rtc/rtc-spear.c
> +++ b/drivers/rtc/rtc-spear.c
> @@ -437,7 +437,7 @@ static int spear_rtc_resume(struct device *dev)
> {
> struct platform_device *pdev = to_platform_device(dev);
> struct spear_rtc_config *config = platform_get_drvdata(pdev);
> - int irq;
> + int irq, ret;
>
> irq = platform_get_irq(pdev, 0);
>
> @@ -447,7 +447,11 @@ static int spear_rtc_resume(struct device *dev)
> config->irq_wake = 0;
> }
> } else {
> - clk_enable(config->clk);
On spear, this function will never fail as this ultimately calls static
void clk_gate_endisable.
> + ret = clk_enable(config->clk);
> + if (ret) {
> + dev_err(dev, "Unable to enable clock on resume: %d\n", ret);
> + return ret;
> + }
> spear_rtc_enable_interrupt(config);
> }
>
> --
> 2.34.1
>
--
Alexandre Belloni, co-owner and COO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
prev parent reply other threads:[~2026-04-12 21:33 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-01 16:19 [PATCH] rtc: spear: check return value of clk_enable in resume Zhaoyang Yu
2026-04-12 21:33 ` Alexandre Belloni [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=20260412213336c5c1e339@mail.local \
--to=alexandre.belloni@bootlin.com \
--cc=2426767509@qq.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rtc@vger.kernel.org \
/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