[PATCH] cpufreq: schedutil: Replace sprintf() with sysfs_emit() in sysfs show

Zhongqiu Han posted 1 patch 1 week, 2 days ago
kernel/sched/cpufreq_schedutil.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] cpufreq: schedutil: Replace sprintf() with sysfs_emit() in sysfs show
Posted by Zhongqiu Han 1 week, 2 days ago
Use sysfs_emit() instead of sprintf() in rate_limit_us_show().

sysfs_emit() is the preferred API for sysfs output as it provides
PAGE_SIZE bounds checking and ensures proper sysfs formatting.

No functional change intended.

Signed-off-by: Zhongqiu Han <zhongqiu.han@oss.qualcomm.com>
---
 kernel/sched/cpufreq_schedutil.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/sched/cpufreq_schedutil.c b/kernel/sched/cpufreq_schedutil.c
index dc0835ceee98..96651873345e 100644
--- a/kernel/sched/cpufreq_schedutil.c
+++ b/kernel/sched/cpufreq_schedutil.c
@@ -592,7 +592,7 @@ static ssize_t rate_limit_us_show(struct gov_attr_set *attr_set, char *buf)
 {
 	struct sugov_tunables *tunables = to_sugov_tunables(attr_set);
 
-	return sprintf(buf, "%u\n", tunables->rate_limit_us);
+	return sysfs_emit(buf, "%u\n", tunables->rate_limit_us);
 }
 
 static ssize_t
-- 
2.43.0
Re: [PATCH] cpufreq: schedutil: Replace sprintf() with sysfs_emit() in sysfs show
Posted by Rafael J. Wysocki (Intel) 3 days, 2 hours ago
On Thu, Jul 16, 2026 at 3:15 PM Zhongqiu Han
<zhongqiu.han@oss.qualcomm.com> wrote:
>
> Use sysfs_emit() instead of sprintf() in rate_limit_us_show().
>
> sysfs_emit() is the preferred API for sysfs output as it provides
> PAGE_SIZE bounds checking and ensures proper sysfs formatting.
>
> No functional change intended.
>
> Signed-off-by: Zhongqiu Han <zhongqiu.han@oss.qualcomm.com>
> ---
>  kernel/sched/cpufreq_schedutil.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/kernel/sched/cpufreq_schedutil.c b/kernel/sched/cpufreq_schedutil.c
> index dc0835ceee98..96651873345e 100644
> --- a/kernel/sched/cpufreq_schedutil.c
> +++ b/kernel/sched/cpufreq_schedutil.c
> @@ -592,7 +592,7 @@ static ssize_t rate_limit_us_show(struct gov_attr_set *attr_set, char *buf)
>  {
>         struct sugov_tunables *tunables = to_sugov_tunables(attr_set);
>
> -       return sprintf(buf, "%u\n", tunables->rate_limit_us);
> +       return sysfs_emit(buf, "%u\n", tunables->rate_limit_us);
>  }
>
>  static ssize_t
> --

Applied as 7.3 material, thanks!