]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
cpufreq: governor: Use sysfs_emit() in sysfs show functions
authorThorsten Blum <thorsten.blum@linux.dev>
Mon, 23 Feb 2026 21:03:51 +0000 (22:03 +0100)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Fri, 6 Mar 2026 18:33:10 +0000 (19:33 +0100)
Replace sprintf() with sysfs_emit() in sysfs show functions.
sysfs_emit() is preferred for formatting sysfs output because it
provides safer bounds checking.  No functional changes.

Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
[ rjw: Subject tweak ]
Link: https://patch.msgid.link/20260223210351.344388-2-thorsten.blum@linux.dev
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
drivers/cpufreq/cpufreq_governor.h

index 168c23fd7fcac75626a070784dce936629adcec2..732fd4d1a803775e1ef3137e16170adf75067188 100644 (file)
@@ -21,6 +21,7 @@
 #include <linux/kernel_stat.h>
 #include <linux/module.h>
 #include <linux/mutex.h>
+#include <linux/sysfs.h>
 
 /* Ondemand Sampling types */
 enum {OD_NORMAL_SAMPLE, OD_SUB_SAMPLE};
@@ -57,7 +58,7 @@ static ssize_t file_name##_show                                               \
 {                                                                      \
        struct dbs_data *dbs_data = to_dbs_data(attr_set);              \
        struct _gov##_dbs_tuners *tuners = dbs_data->tuners;            \
-       return sprintf(buf, "%u\n", tuners->file_name);                 \
+       return sysfs_emit(buf, "%u\n", tuners->file_name);              \
 }
 
 #define gov_show_one_common(file_name)                                 \
@@ -65,7 +66,7 @@ static ssize_t file_name##_show                                               \
 (struct gov_attr_set *attr_set, char *buf)                             \
 {                                                                      \
        struct dbs_data *dbs_data = to_dbs_data(attr_set);              \
-       return sprintf(buf, "%u\n", dbs_data->file_name);               \
+       return sysfs_emit(buf, "%u\n", dbs_data->file_name);            \
 }
 
 #define gov_attr_ro(_name)                                             \