[clocksource: timers/drivers/next] clocksource/drivers/timer-mediatek: Fix "no-cfi indirect call" warning

From: clocksource-bot for Luca Leonardo Scorcia

Date: Wed Nov 25 2026 - 13:18:45 EST


The following commit has been merged into the timers/drivers/next branch of clocksource:

Commit-ID: 4b949fed24d8ad8fa0b046391869c37a9b1c213f
Gitweb: https://git.kernel.org/pub/scm/linux/kernel/git/daniel.lezcano/linux.git//4b949fed24d8ad8fa0b046391869c37a9b1c213f
Author: Luca Leonardo Scorcia <l.scorcia@xxxxxxxxx>
AuthorDate: Sun, 01 Nov 2026 10:55:31 +01:00
Committer: Daniel Lezcano <daniel.lezcano@xxxxxxxxxx>
CommitterDate: Wed, 25 Nov 2026 18:16:45 +01:00

clocksource/drivers/timer-mediatek: Fix "no-cfi indirect call" warning

After converting the driver to OF probing, kernel-test-robot reported the
following new warning:

vmlinux.o: warning: objtool: mtk_timer_probe+0x23: no-cfi indirect call!

This occurs because of_device_get_match_data() returns NULL when
CONFIG_OF is disabled, which results in LLVM dropping the kCFI setup
since it knows that there is no valid target for this call. Adding a
check for a NULL timer_init avoids the warning and it makes the probe
more robust since of_device_get_match_data() could return NULL even
when CONFIG_OF=y.

Fixes: 7a097aba7255 ("clocksource/drivers/timer-mediatek: Convert to OF probing")
Reported-by: kernel test robot <lkp@xxxxxxxxx>
Closes: https://lore.kernel.org/oe-kbuild-all/202610290223.iOEGeDs2-lkp@xxxxxxxxx/
Suggested-by: Nathan Chancellor <nathan@xxxxxxxxxx>
Signed-off-by: Luca Leonardo Scorcia <l.scorcia@xxxxxxxxx>
Signed-off-by: Daniel Lezcano <daniel.lezcano@xxxxxxxxxx>
Reviewed-by: Nathan Chancellor <nathan@xxxxxxxxxx>
Link: https://patch.msgid.link/20261101095538.1046918-1-l.scorcia@xxxxxxxxx
---
drivers/clocksource/timer-mediatek.c | 3 +++
1 file changed, 3 insertions(+)

diff --git a/drivers/clocksource/timer-mediatek.c b/drivers/clocksource/timer-mediatek.c
index 558bc75..764c30c 100644
--- a/drivers/clocksource/timer-mediatek.c
+++ b/drivers/clocksource/timer-mediatek.c
@@ -366,6 +366,9 @@ static int mtk_timer_probe(struct platform_device *pdev)
int (*timer_init)(struct platform_device *pdev);

timer_init = of_device_get_match_data(&pdev->dev);
+ if (!timer_init)
+ return -ENODEV;
+
return timer_init(pdev);
}