]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
irqchip/gic-v3: Iterate over possible CPUs by for_each_possible_cpu()
authorzijun_hu <zijun_hu@htc.com>
Fri, 15 Sep 2017 17:59:41 +0000 (01:59 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 25 Jun 2022 09:45:18 +0000 (11:45 +0200)
[ Upstream commit 3fad4cdac235c5b13227d0c09854c689ae62c70b ]

get_cpu_number() doesn't use existing helper to iterate over possible
CPUs, It will cause an error in case of discontinuous @cpu_possible_mask
such as 0b11110001, which can result from a core having failed to come
up on a SMP machine.

Fixed by using existing helper for_each_possible_cpu().

Signed-off-by: zijun_hu <zijun_hu@htc.com>
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/irqchip/irq-gic-v3.c

index 2ab6060031a433da0f32db810bc30160f68a607b..9ae24ffb9b09ca5a5d57ca920b499d98d5902811 100644 (file)
@@ -982,7 +982,7 @@ static int get_cpu_number(struct device_node *dn)
 {
        const __be32 *cell;
        u64 hwid;
-       int i;
+       int cpu;
 
        cell = of_get_property(dn, "reg", NULL);
        if (!cell)
@@ -996,9 +996,9 @@ static int get_cpu_number(struct device_node *dn)
        if (hwid & ~MPIDR_HWID_BITMASK)
                return -1;
 
-       for (i = 0; i < num_possible_cpus(); i++)
-               if (cpu_logical_map(i) == hwid)
-                       return i;
+       for_each_possible_cpu(cpu)
+               if (cpu_logical_map(cpu) == hwid)
+                       return cpu;
 
        return -1;
 }