Misc CPU hotplug fixes:

- Fix CPU hotplug error handling rollback bug
    (Bradley Morgan)
 
  - Fix possible output OOB write bug in the sysfs
    hotplug states printing code (Bradley Morgan)
 
 Signed-off-by: Ingo Molnar <mingo@kernel.org>
 -----BEGIN PGP SIGNATURE-----
 
 iQJFBAABCgAvFiEEBpT5eoXrXCwVQwEKEnMQ0APhK1gFAmo6vV4RHG1pbmdvQGtl
 cm5lbC5vcmcACgkQEnMQ0APhK1gnTQ//aiMJIdWbtSusi24hgGo1rCy+xUcezPPq
 6C8MeR26ANvlr1fHmf2N2FV11zEA/XfEgJSf1Vyi+I0csOn5gGrIXgbMKpAi0+YK
 hVi4pndad3YJ5LReT/TeTb0bYXHz9SkAYcRHWB9U3giCQsYHhdu/f3emia8DW/Ll
 OlpS+XI07xlUS/2/M86OkshK9AkssJFU6sv9PY3kebCxgZhdeK9J2LSGTf+jDOC3
 rmHGGPD6QUGK34rxd6uaxjo3FnAB6QshALAvb1AtZkcKzz0fO3sHOCouxKWdEc+L
 l7qhfEJi1uHnoaYCx5X+50XdLnSsGwHU1fMn0EZ3dvbm0qE6BxSr4fvZ+iouy4bs
 p3xzk39aeTmNJhXNFKnlLyhd9otORS78QKrHPblVY3+PuFL8Xob0dEcHyGywja3g
 KBBpATOebWLv6Qr02KwWEsDrBLtbWyNNHYSNUjmpvBdaV7vH+sGZ3N3jz6ADp8CR
 2hiKdJZvcSGOxDjRpwAXSsTiKQNrWAGFbz3wQFB0fupYJgWfP0MrUg8i8wEkbfqy
 FHF47rNpYKDmWJMLXmCFxOo+YeWHE7MuFesf4SpDp3c+WhrjkMcA/6l/IjycyXze
 GH21Wipu2YkIxZ/4FEdVHDgpozkHlIParBUip6t2i9RNKkcLodg18OCYmFk0MWCM
 UzOkVoD9sq8=
 =2MfA
 -----END PGP SIGNATURE-----

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
commit 83db48fb03

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;