Skip to content

Commit 2488444

Browse files
jic23ctmarinas
authored andcommitted
arm64: acpi: Harden get_cpu_for_acpi_id() against missing CPU entry
In a review discussion of the changes to support vCPU hotplug where a check was added on the GICC being enabled if was online, it was noted that there is need to map back to the cpu and use that to index into a cpumask. As such, a valid ID is needed. If an MPIDR check fails in acpi_map_gic_cpu_interface() it is possible for the entry in cpu_madt_gicc[cpu] == NULL. This function would then cause a NULL pointer dereference. Whilst a path to trigger this has not been established, harden this caller against the possibility. Reviewed-by: Gavin Shan <[email protected]> Signed-off-by: Jonathan Cameron <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Catalin Marinas <[email protected]>
1 parent 8d34b6f commit 2488444

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

arch/arm64/include/asm/acpi.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,8 @@ static inline int get_cpu_for_acpi_id(u32 uid)
124124
int cpu;
125125

126126
for (cpu = 0; cpu < nr_cpu_ids; cpu++)
127-
if (uid == get_acpi_id_for_cpu(cpu))
127+
if (acpi_cpu_get_madt_gicc(cpu) &&
128+
uid == get_acpi_id_for_cpu(cpu))
128129
return cpu;
129130

130131
return -EINVAL;

0 commit comments

Comments
 (0)