[clocksource: timers/drivers/next] clocksource/drivers/sh_mtu2: Fix the size for the irq name buffer
From: clocksource-bot for xujiahao
Date: Wed Nov 25 2026 - 13:18:50 EST
The following commit has been merged into the timers/drivers/next branch of clocksource:
Commit-ID: 097e8c57c1fac343c545c0abcb404a874b8d7217
Gitweb: https://git.kernel.org/pub/scm/linux/kernel/git/daniel.lezcano/linux.git//097e8c57c1fac343c545c0abcb404a874b8d7217
Author: xujiahao <xujiahao@xxxxxxxxxxxxxxxxxxxx>
AuthorDate: Thu, 05 Nov 2026 10:57:18 +08:00
Committer: Daniel Lezcano <daniel.lezcano@xxxxxxxxxx>
CommitterDate: Wed, 25 Nov 2026 17:59:16 +01:00
clocksource/drivers/sh_mtu2: Fix the size for the irq name buffer
sh_mtu2_setup_channel() formats the per-channel interrupt name into a
6-byte buffer:
char name[6];
sprintf(name, "tgi%ua", index);
which only has room for a single-digit index. gcc reports with W=1:
sh_mtu2.c:348:27: warning: '%u' directive writing between 1 and 10
bytes into a region of size 3 [-Wformat-overflow=]
Callers pass indices below ARRAY_SIZE(sh_mtu2_channel_offsets), that is
at most 2, so the overflow is not reachable today. Still, the buffer
size does not match what the format string allows, and the bound lives
in the caller rather than in this function.
Size the buffer for the widest possible unsigned int, which makes the
sprintf() correct for any index.
No functional change.
Reported-by: kernel test robot <lkp@xxxxxxxxx>
Closes: https://lore.kernel.org/all/202501080036.LH3XAQK1-lkp@xxxxxxxxx/
Signed-off-by: xujiahao <xujiahao@xxxxxxxxxxxxxxxxxxxx>
Signed-off-by: Daniel Lezcano <daniel.lezcano@xxxxxxxxxx>
Link: https://patch.msgid.link/20261105025718.524-1-xujiahao@xxxxxxxxxxxxxxxxxxxx
---
drivers/clocksource/sh_mtu2.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/clocksource/sh_mtu2.c b/drivers/clocksource/sh_mtu2.c
index a45bf94..5d1ce87 100644
--- a/drivers/clocksource/sh_mtu2.c
+++ b/drivers/clocksource/sh_mtu2.c
@@ -339,7 +339,7 @@ static const unsigned int sh_mtu2_channel_offsets[] = {
static int sh_mtu2_setup_channel(struct sh_mtu2_channel *ch, unsigned int index,
struct sh_mtu2_device *mtu)
{
- char name[6];
+ char name[16];
int irq;
int ret;