LinuxPPC-Dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Gou Hao <gouhao@uniontech.com>
To: maddy@linux.ibm.com, mpe@ellerman.id.au, npiggin@gmail.com,
	chleroy@kernel.org, namcao@linutronix.de, peterz@infradead.org,
	sshegde@linux.ibm.com, kees@kernel.org,
	lgs201920130244@gmail.com, srikar@linux.ibm.com,
	ynorov@nvidia.com, nilay@linux.ibm.com, clg@kaod.org,
	benh@kernel.crashing.org, miltonm@bga.com, mkchauras@gmail.com,
	akpm@linux-foundation.org
Cc: linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org,
	gouhaojake@163.com, kernel@uniontech.com
Subject: [PATCH v3 5/5] powerpc/smp: add NULL guard for cause_ipi in smp_muxed_ipi_message_pass
Date: Mon, 27 Jul 2026 18:42:15 +0800	[thread overview]
Message-ID: <20260727104215.184786-6-gouhao@uniontech.com> (raw)
In-Reply-To: <20260727104215.184786-1-gouhao@uniontech.com>

smp_muxed_ipi_message_pass() calls smp_ops->cause_ipi() without
checking whether it has been set.

On platforms using muxed IPI (e.g. powernv/pseries), smp_ops->cause_ipi
is initialized to NULL in the static smp_ops and only assigned during
the platform smp_probe() handler.  If the IPI subsystem fails to
initialize -- for example when xive_init_ipis() fails and
xive_smp_probe() returns an error -- the probe handler returns early
and cause_ipi is never set.  Any subsequent IPI send (e.g.
arch_smp_send_reschedule()) would dereference the NULL pointer.

Add a NULL check to avoid the crash in that situation.

Fixes: 23d72bfd8f9f ("powerpc: Consolidate ipi message mux and demux")
Signed-off-by: Gou Hao <gouhao@uniontech.com>
Reviewed-by: jiazhenyuan <jiazhenyuan@uniontech.com>
---
 arch/powerpc/kernel/smp.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/arch/powerpc/kernel/smp.c b/arch/powerpc/kernel/smp.c
index 3467f86fd78f..6a5a5469aaae 100644
--- a/arch/powerpc/kernel/smp.c
+++ b/arch/powerpc/kernel/smp.c
@@ -289,6 +289,9 @@ void smp_muxed_ipi_set_message(int cpu, int msg)
 
 void smp_muxed_ipi_message_pass(int cpu, int msg)
 {
+	if (!smp_ops->cause_ipi)
+		return;
+
 	smp_muxed_ipi_set_message(cpu, msg);
 
 	/*
-- 
2.20.1



      parent reply	other threads:[~2026-07-27 10:43 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-27 10:42 [PATCH v3 0/5] powerpc/xive: remove __GFP_NOFAIL and fix IPI error handling Gou Hao
2026-07-27 10:42 ` [PATCH v3 1/5] powerpc/xive: make xive IPI allocation NULL-safe Gou Hao
2026-07-27 10:42 ` [PATCH v3 2/5] powerpc/xive: add error return value to xive_smp_probe() Gou Hao
2026-07-27 10:42 ` [PATCH v3 3/5] powerpc/xive: propagate IPI init errors to prevent use-after-free Gou Hao
2026-07-28  2:47   ` Srikar Dronamraju
2026-07-28 10:26     ` Gou Hao
2026-07-27 10:42 ` [PATCH v3 4/5] powerpc/xive: defer setting cause_ipi until IPI init succeeds Gou Hao
2026-07-27 10:42 ` Gou Hao [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260727104215.184786-6-gouhao@uniontech.com \
    --to=gouhao@uniontech.com \
    --cc=akpm@linux-foundation.org \
    --cc=benh@kernel.crashing.org \
    --cc=chleroy@kernel.org \
    --cc=clg@kaod.org \
    --cc=gouhaojake@163.com \
    --cc=kees@kernel.org \
    --cc=kernel@uniontech.com \
    --cc=lgs201920130244@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=maddy@linux.ibm.com \
    --cc=miltonm@bga.com \
    --cc=mkchauras@gmail.com \
    --cc=mpe@ellerman.id.au \
    --cc=namcao@linutronix.de \
    --cc=nilay@linux.ibm.com \
    --cc=npiggin@gmail.com \
    --cc=peterz@infradead.org \
    --cc=srikar@linux.ibm.com \
    --cc=sshegde@linux.ibm.com \
    --cc=ynorov@nvidia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox