]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
thermal: intel: Use sysfs_emit() in a sysfs show function
authorThorsten Blum <thorsten.blum@linux.dev>
Tue, 13 Jan 2026 08:21:26 +0000 (09:21 +0100)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Thu, 15 Jan 2026 20:21:16 +0000 (21:21 +0100)
Replace sprintf() with sysfs_emit() in sysfs show functions.

sysfs_emit() is preferred to format sysfs output as it provides better
bounds checking.

Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
[ rjw: Subject tweaks ]
Link: https://patch.msgid.link/20260113082130.789891-2-thorsten.blum@linux.dev
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
drivers/thermal/intel/therm_throt.c

index debc94e2dc169775752cb88b6aaa5fa308f09902..44fa4dd15dd1c5313d35e332e5d7c9455dc361ff 100644 (file)
@@ -23,6 +23,7 @@
 #include <linux/types.h>
 #include <linux/init.h>
 #include <linux/smp.h>
+#include <linux/sysfs.h>
 #include <linux/cpu.h>
 
 #include <asm/processor.h>
@@ -144,8 +145,8 @@ static ssize_t therm_throt_device_show_##event##_##name(            \
                                                                        \
        preempt_disable();      /* CPU hotplug */                       \
        if (cpu_online(cpu)) {                                          \
-               ret = sprintf(buf, "%lu\n",                             \
-                             per_cpu(thermal_state, cpu).event.name);  \
+               ret = sysfs_emit(buf, "%lu\n",                          \
+                       per_cpu(thermal_state, cpu).event.name);        \
        } else                                                          \
                ret = 0;                                                \
        preempt_enable();                                               \