]> git.baikalelectronics.ru Git - kernel.git/commitdiff
powerpc/powernv: Get cpu only after validity check
authorSantosh Sivaraj <santosh@fossix.org>
Tue, 4 Jul 2017 04:22:46 +0000 (09:52 +0530)
committerMichael Ellerman <mpe@ellerman.id.au>
Mon, 24 Jul 2017 11:17:55 +0000 (21:17 +1000)
Check for validity of cpu before calling get_hard_smp_processor_id().

Found with coverity.

Signed-off-by: Santosh Sivaraj <santosh@fossix.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
arch/powerpc/platforms/powernv/smp.c

index 40dae96f7e20c6d2c1446e89f770e031c70e13f8..c6448c7aabe7ae05795f9f80302d7d3b7cd3a47f 100644 (file)
@@ -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