summaryrefslogtreecommitdiff
path: root/kernel
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2026-06-23 16:43:24 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2026-06-23 16:43:24 -0700
commit83db48fb03fc4b14bc1a66d3c189030552f0c8bc (patch)
treec62e53fa03495268679945a4a1c1b8821e09ed3a /kernel
parentd88eb9b84343b5f8d1b39b6c83280ce8aaeab6d8 (diff)
parent86f436567f2516a0083b210bedc933544826a2c3 (diff)
downloadlwn-83db48fb03fc4b14bc1a66d3c189030552f0c8bc.tar.gz
lwn-83db48fb03fc4b14bc1a66d3c189030552f0c8bc.zip
Merge tag 'smp-urgent-2026-06-23' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull misc CPU hotplug fixes from Ingo Molnar: - Fix CPU hotplug error handling rollback bug (Bradley Morgan) - Fix possible output OOB write bug in the sysfs hotplug states printing code (Bradley Morgan) * tag 'smp-urgent-2026-06-23' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: cpu: hotplug: Bound hotplug states sysfs output cpu: hotplug: Preserve per instance callback errors
Diffstat (limited to 'kernel')
-rw-r--r--kernel/cpu.c20
1 files changed, 8 insertions, 12 deletions
diff --git a/kernel/cpu.c b/kernel/cpu.c
index f975bb34915b..b3c8553d7bd6 100644
--- a/kernel/cpu.c
+++ b/kernel/cpu.c
@@ -174,7 +174,7 @@ static int cpuhp_invoke_callback(unsigned int cpu, enum cpuhp_state state,
struct cpuhp_step *step = cpuhp_get_step(state);
int (*cbm)(unsigned int cpu, struct hlist_node *node);
int (*cb)(unsigned int cpu);
- int ret, cnt;
+ int ret, cnt, rollback_ret;
if (st->fail == state) {
st->fail = CPUHP_INVALID;
@@ -238,12 +238,12 @@ err:
break;
trace_cpuhp_multi_enter(cpu, st->target, state, cbm, node);
- ret = cbm(cpu, node);
- trace_cpuhp_exit(cpu, st->state, state, ret);
+ rollback_ret = cbm(cpu, node);
+ trace_cpuhp_exit(cpu, st->state, state, rollback_ret);
/*
* Rollback must not fail,
*/
- WARN_ON_ONCE(ret);
+ WARN_ON_ONCE(rollback_ret);
}
return ret;
}
@@ -2854,21 +2854,17 @@ static const struct attribute_group cpuhp_cpu_attr_group = {
.name = "hotplug",
};
-static ssize_t states_show(struct device *dev,
- struct device_attribute *attr, char *buf)
+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;