From: Ian Rogers <irogers@google.com>
To: Daniel Lezcano <daniel.lezcano@kernel.org>,
Thomas Gleixner <tglx@kernel.org>
Cc: linux-kernel@vger.kernel.org, llvm@lists.linux.dev,
Elkin Cruz <elkin@google.com>, Ian Rogers <irogers@google.com>
Subject: [PATCH] clocksource/drivers/timer-mediatek: Check devm_clk_get_optional_enabled() for errors
Date: Thu, 19 Nov 2026 09:06:29 -0800 [thread overview]
Message-ID: <20261119170629.1520297-1-irogers@google.com> (raw)
mtk_gpt_init() stores the return value of devm_clk_get_optional_enabled()
in 'clk_bus' without checking IS_ERR(clk_bus). If the optional "bus" clock
requires probe deferral (-EPROBE_DEFER) or fails to enable, mtk_gpt_init()
ignores the error and proceeds to access timer MMIO registers with the bus
clock disabled.
Return PTR_ERR(clk_bus) when IS_ERR(clk_bus) is true.
Found via an x86_64 LLVM=1 (Clang 21.1.8) allyesconfig audit with
-Wunused-but-set-variable enabled; fix and changelog drafted with an AI
coding assistant. Build-tested under LLVM=1 W=1 and
-Wunused-but-set-variable (CONFIG_MTK_TIMER=y via CONFIG_COMPILE_TEST);
not boot-tested on MediaTek SoC hardware.
Fixes: e234d4082380 ("clocksource/drivers/timer-mediatek: Request and enable the bus clock")
Signed-off-by: Ian Rogers <irogers@google.com>
---
drivers/clocksource/timer-mediatek.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/clocksource/timer-mediatek.c b/drivers/clocksource/timer-mediatek.c
index 842d6ee4259e..860d4eb3f8f7 100644
--- a/drivers/clocksource/timer-mediatek.c
+++ b/drivers/clocksource/timer-mediatek.c
@@ -314,6 +314,8 @@ static int mtk_gpt_init(struct platform_device *pdev)
int ret;
clk_bus = devm_clk_get_optional_enabled(&pdev->dev, "bus");
+ if (IS_ERR(clk_bus))
+ return PTR_ERR(clk_bus);
to.clkevt.features = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT;
to.clkevt.set_state_shutdown = mtk_gpt_clkevt_shutdown;
--
2.56.1.708.g77570a6a1d-goog
reply other threads:[~2026-11-19 17:06 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20261119170629.1520297-1-irogers@google.com \
--to=irogers@google.com \
--cc=daniel.lezcano@kernel.org \
--cc=elkin@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=llvm@lists.linux.dev \
--cc=tglx@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
all inboxes | Powered by JetHome®