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
This commit is contained in:
Linus Torvalds
2026-06-23 16:43:24 -07:00

View File

@@ -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 @@ static int cpuhp_invoke_callback(unsigned int cpu, enum cpuhp_state state,
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;