TF-TF: Fix bug in calculation of number of CPUs
This patch fixes the bug in tftf_get_total_aff_count()
which incorrectly calculates the number of CPUs for
aff_lvl = 0. The function reads tftf_pd_nodes[] array
only based on condition
`tftf_pd_nodes[node_idx].level == aff_lvl` but
doesn't check for `indexes < PLATFORM_NUM_AFFS`.
This causes reads of the array beyond its boundaries
which results in incorrect calculation of number of CPUs,
and some of the tests entering infinite loops.
Signed-off-by: Alexei Fedorov <Alexei.Fedorov@arm.com>
Change-Id: If7b2d8eba7560126aeff29c6b8c9355198aad453
diff --git a/plat/common/plat_topology.c b/plat/common/plat_topology.c
index 01e3461..33b6e57 100644
--- a/plat/common/plat_topology.c
+++ b/plat/common/plat_topology.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018, Arm Limited. All rights reserved.
+ * Copyright (c) 2018-2019, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
@@ -86,7 +86,8 @@
node_idx = tftf_pwr_domain_start_idx[aff_lvl];
- while (tftf_pd_nodes[node_idx].level == aff_lvl) {
+ while ((node_idx < PLATFORM_NUM_AFFS) &&
+ (tftf_pd_nodes[node_idx].level == aff_lvl)) {
if (tftf_pd_nodes[node_idx].is_present)
count++;
node_idx++;