* [PATCH] cpu/hotplug: Use sysfs_emit_at() in states_show()
@ 2026-07-04 17:48 Bradley Morgan
0 siblings, 0 replies; only message in thread
From: Bradley Morgan @ 2026-07-04 17:48 UTC (permalink / raw)
To: Thomas Gleixner, Peter Zijlstra; +Cc: linux-kernel
Replace raw sprintf() and manual buffer arithmetic with sysfs_emit_at(),
which bounds output to PAGE_SIZE.
Signed-off-by: Bradley Morgan <include@grrlz.net>
---
kernel/cpu.c | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/kernel/cpu.c b/kernel/cpu.c
index f975bb34915b..25d88cf2bb15 100644
--- a/kernel/cpu.c
+++ b/kernel/cpu.c
@@ -2857,18 +2857,15 @@ static const struct attribute_group cpuhp_cpu_attr_group = {
static ssize_t states_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
- ssize_t cur, res = 0;
+ ssize_t res = 0;
int i;
mutex_lock(&cpuhp_state_mutex);
for (i = CPUHP_OFFLINE; i <= CPUHP_ONLINE; i++) {
struct cpuhp_step *sp = cpuhp_get_step(i);
- if (sp->name) {
- cur = sprintf(buf, "%3d: %s\n", i, sp->name);
- buf += cur;
- res += cur;
- }
+ if (sp->name)
+ res += sysfs_emit_at(buf, res, "%3d: %s\n", i, sp->name);
}
mutex_unlock(&cpuhp_state_mutex);
return res;
--
2.53.0
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-07-04 17:48 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-04 17:48 [PATCH] cpu/hotplug: Use sysfs_emit_at() in states_show() Bradley Morgan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox