Hi Anggara, > Date: 2026-12-04 10:38:08+0700 > From: Anggara Putra > > "kirkwood-cpufreq" fills all 16 bytes of the driver name. The > scaling_driver attribute formats it with %s, and its 17-byte > output limit leaves room for only 16 characters and the NUL. > > Reserve a byte for the driver's name terminator and use sysfs_emit() > to fit the complete name and newline. Governor names keep their > existing size. > > OpenAI Codex assisted with the patch, commit message, and local tests > using the public KSPP compiler diagnostics. > > Fixes: 2a4bd9f0db24 ("cpufreq: kirkwood: Add a cpufreq driver for > Marvell Kirkwood SoCs") > Link: https://github.com/KSPP/linux/issues/374 > Signed-off-by: Anggara Putra > --- > The Kirkwood driver and CPUfreq core built for ARM. In the rebuilt > driver object, the 17-byte name field contains "kirkwood-cpufreq" > followed by its terminating NUL. > The scaling_driver attribute was not read on Kirkwood hardware. > > drivers/cpufreq/cpufreq.c | 2 +- > include/linux/cpufreq.h | 4 +--- > 2 files changed, 2 insertions(+), 4 deletions(-) > > diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c > index 4332cb1..a6885e1 100644 > --- a/drivers/cpufreq/cpufreq.c > +++ b/drivers/cpufreq/cpufreq.c > @@ -841,7 +841,7 @@ > */ > static ssize_t show_scaling_driver(struct cpufreq_policy *policy, char *buf) > { > - return scnprintf(buf, CPUFREQ_NAME_PLEN, "%s\n", cpufreq_driver->name); > + return sysfs_emit(buf, "%s\n", cpufreq_driver->name); How does this know the buffer size? Won't this overflow the buffer given a too-long string? Have a lovely day! Alex > } > > /* > diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h > index be1eaa4..0f6c0f5 100644 > --- a/include/linux/cpufreq.h > +++ b/include/linux/cpufreq.h > @@ -31,8 +31,6 @@ > #define CPUFREQ_DEFAULT_TRANSITION_LATENCY_NS NSEC_PER_MSEC > > #define CPUFREQ_NAME_LEN 16 > -/* Print length for names. Extra 1 space for accommodating '\n' in prints */ > -#define CPUFREQ_NAME_PLEN (CPUFREQ_NAME_LEN + 1) > > struct cpufreq_governor; > > @@ -353,7 +351,7 @@ __ATTR(_name, 0644, show_##_name, store_##_name) > > > struct cpufreq_driver { > - char name[CPUFREQ_NAME_LEN]; > + char name[CPUFREQ_NAME_LEN + 1]; > u16 flags; > void *driver_data; > --