cpu/hotplug: Use sysfs_emit_at() in states_show()
PATCH 1/1 cpu/hotplug: Use sysfs_emit_at() in states_show()
Replace raw sprintf() and manual buffer arithmetic with sysfs_emit_at(), which bounds output to PAGE_SIZE.
Signed-off-by Bradley Morgan <[email protected]>
--- kernel/cpu.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)
kernel/cpu.c +3 -6
@@ -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;
Signature · 1 line
2.53.0
Thomas Gleixner
maintainerQuoted 2 lines · Bradley Morgan
Replace raw
sprintf()and manual buffer arithmetic withsysfs_emit_at(), which bounds output toPAGE_SIZE.
Seems you failed to keep track of your patch flood. :)
86f436567f25 ("cpu: hotplug: Bound hotplug states sysfs output")