From: Bowen Yu <yubowen8@huawei.com> driver inclusion category: bugfix bugzilla: https://atomgit.com/openeuler/kernel/issues/9163 ---------------------------------------------------------------------- Replace sprintf() and scnprintf() with sysfs_emit() and sysfs_emit_at() in the cpufreq core. This ensures safer buffer handling and consistency with sysfs interfaces. Fixes: 3ed783c89579 ("smart_grid: cpufreq: introduce smart_grid cpufreq control") Signed-off-by: Bowen Yu <yubowen8@huawei.com> Signed-off-by: Hongye Lin <linhongye@h-partners.com> --- drivers/cpufreq/cpufreq.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index 117591212850..0fef63158f10 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -2917,11 +2917,11 @@ static ssize_t show_smart_grid_governor(struct kobject *kobj, mutex_lock(&sg_zone_lock); if (!sg_zone.enable) { mutex_unlock(&sg_zone_lock); - return sprintf(buf, "smart_grid governor disable\n"); + return sysfs_emit(buf, "smart_grid governor disable\n"); } for (gov_index = 0; gov_index < SMART_GRID_ZONE_NR; gov_index++) - len += sprintf(buf + len, "smart_grid-%d: %s\n", gov_index, + len += sysfs_emit_at(buf, len, "smart_grid-%d: %s\n", gov_index, sg_zone.governor_name[gov_index]); mutex_unlock(&sg_zone_lock); @@ -2992,7 +2992,7 @@ define_one_global_rw(smart_grid_governor); static ssize_t show_smart_grid_governor_enable(struct kobject *kobj, struct kobj_attribute *attr, char *buf) { - return sprintf(buf, "%u\n", sg_zone.enable); + return sysfs_emit(buf, "%u\n", sg_zone.enable); } static void smart_grid_irq_work(struct irq_work *irq_work) -- 2.33.0