]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
powerpc/powernv: fix preempt count leak in pnv_kexec_wait_secondaries_down
authorAboorva Devarajan <aboorvad@linux.ibm.com>
Fri, 5 Jun 2026 08:29:11 +0000 (13:59 +0530)
committerMadhavan Srinivasan <maddy@linux.ibm.com>
Mon, 15 Jun 2026 10:55:21 +0000 (16:25 +0530)
pnv_kexec_wait_secondaries_down() calls get_cpu() to obtain the current
CPU id but never calls the matching put_cpu(), leaking one
preempt_disable() nesting level on every invocation.

In practice the imbalance does not trigger a visible splat because the
kexec teardown path is a one-way trip: IRQs are already disabled, no
schedule() occurs after the leak, and default_machine_kexec() overwrites
preempt_count with HARDIRQ_OFFSET before jumping into kexec_sequence()
which never returns. However the bookkeeping is still wrong.

The function only needs the current CPU id, and this path runs with
interrupts disabled and the CPU pinned, so the preempt_disable()
side-effect of get_cpu() is unnecessary. Replace it with
raw_smp_processor_id().

Fixes: 298b34d7d578 ("powerpc/powernv: Fix kexec races going back to OPAL")
Signed-off-by: Aboorva Devarajan <aboorvad@linux.ibm.com>
Signed-off-by: Madhavan Srinivasan <maddy@linux.ibm.com>
Link: https://patch.msgid.link/20260605082912.305100-3-aboorvad@linux.ibm.com
arch/powerpc/platforms/powernv/setup.c

index 4dbb47ddbdcc4bef99b56a5ef4cee95b53f22aa2..06ed5e2aa265847458fbbd0de37151f6dac24a98 100644 (file)
@@ -396,7 +396,8 @@ static void pnv_kexec_wait_secondaries_down(void)
 {
        int my_cpu, i, notified = -1;
 
-       my_cpu = get_cpu();
+       /* Called with interrupts disabled, so the CPU is pinned. */
+       my_cpu = raw_smp_processor_id();
 
        for_each_online_cpu(i) {
                uint8_t status;