From: Zhaoyang Yu <2426767509@qq.com>
To: alexandre.belloni@bootlin.com
Cc: linux-rtc@vger.kernel.org, linux-kernel@vger.kernel.org,
Zhaoyang Yu <2426767509@qq.com>
Subject: [PATCH] rtc: spear: check return value of clk_enable in resume
Date: Sun, 1 Mar 2026 16:19:58 +0000 [thread overview]
Message-ID: <tencent_6BA6C87DB3B5EE61C7A22CADE9F5DBBCC90A@qq.com> (raw)
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);
+ 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
next reply other threads:[~2026-03-01 16:23 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-01 16:19 Zhaoyang Yu [this message]
2026-04-12 21:33 ` [PATCH] rtc: spear: check return value of clk_enable in resume Alexandre Belloni
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=tencent_6BA6C87DB3B5EE61C7A22CADE9F5DBBCC90A@qq.com \
--to=2426767509@qq.com \
--cc=alexandre.belloni@bootlin.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