diff mbox

powerpc/smp: Get cpu only after validity check

Message ID 20170704042246.22609-1-santosh@fossix.org (mailing list archive)
State Accepted
Commit 76d98ab4628bf8d36498e8228a5b92aa95a4b820
Headers show

Commit Message

Santosh Sivaraj July 4, 2017, 4:22 a.m. UTC
Check for validity of cpu before calling get_hard_smp_processor_id.

Found with coverity.

Signed-off-by: Santosh Sivaraj <santosh@fossix.org>
---
 arch/powerpc/platforms/powernv/smp.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Michael Ellerman July 27, 2017, 12:37 p.m. UTC | #1
On Tue, 2017-07-04 at 04:22:46 UTC, Santosh Sivaraj wrote:
> Check for validity of cpu before calling get_hard_smp_processor_id.
> 
> Found with coverity.
> 
> Signed-off-by: Santosh Sivaraj <santosh@fossix.org>

Applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/76d98ab4628bf8d36498e8228a5b92

cheers
diff mbox

Patch

diff --git a/arch/powerpc/platforms/powernv/smp.c b/arch/powerpc/platforms/powernv/smp.c
index 40dae96..c6448c7 100644
--- a/arch/powerpc/platforms/powernv/smp.c
+++ b/arch/powerpc/platforms/powernv/smp.c
@@ -57,7 +57,7 @@  static void pnv_smp_setup_cpu(int cpu)
 
 static int pnv_smp_kick_cpu(int nr)
 {
-	unsigned int pcpu = get_hard_smp_processor_id(nr);
+	unsigned int pcpu;
 	unsigned long start_here =
 			__pa(ppc_function_entry(generic_secondary_smp_init));
 	long rc;
@@ -66,6 +66,7 @@  static int pnv_smp_kick_cpu(int nr)
 	if (nr < 0 || nr >= nr_cpu_ids)
 		return -EINVAL;
 
+	pcpu = get_hard_smp_processor_id(nr);
 	/*
 	 * If we already started or OPAL is not supported, we just
 	 * kick the CPU via the PACA