]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
cpu: hotplug: Preserve per instance callback errors
authorBradley Morgan <include@grrlz.net>
Fri, 19 Jun 2026 16:37:17 +0000 (16:37 +0000)
committerThomas Gleixner <tglx@kernel.org>
Sun, 21 Jun 2026 18:44:00 +0000 (20:44 +0200)
cpuhp_invoke_callback() unwinds earlier callbacks for the same
hotplug state when one instance fails. The rollback path currently
reuses ret, so a successful rollback can hide the original error and
make the failed transition look successful.

Keep the rollback result separate from the original error.

Fixes: 724a86881d03 ("smp/hotplug: Callback vs state-machine consistency")
Signed-off-by: Bradley Morgan <include@grrlz.net>
Signed-off-by: Thomas Gleixner <tglx@kernel.org>
Cc: stable@vger.kernel.org
Link: https://patch.msgid.link/20260619163719.12103-1-include@grrlz.net
kernel/cpu.c

index 8df2d773fe3b5258caf5ab01539650294a474843..3ed24c711e3f856ed42adebdcaa9c7715238c062 100644 (file)
@@ -175,7 +175,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;
@@ -239,12 +239,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;
 }