diff options
author | Alexei Fedorov <Alexei.Fedorov@arm.com> | 2019-07-16 09:34:24 +0100 |
---|---|---|
committer | Alexei Fedorov <Alexei.Fedorov@arm.com> | 2019-07-17 16:41:54 +0100 |
commit | 8dec845212bede5e127ef7293e0b20c9e02195ed (patch) | |
tree | 32c429ca955deda4928c94b5bef2618ee87bb1f8 | |
parent | 7bdfa0b07a52e487a443394aad89bcd37fbc02a8 (diff) | |
download | tf-a-tests-8dec845212bede5e127ef7293e0b20c9e02195ed.tar.gz |
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
-rw-r--r-- | plat/common/plat_topology.c | 5 |
1 files changed, 3 insertions, 2 deletions
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 @@ unsigned int tftf_get_total_aff_count(unsigned int aff_lvl) 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++; |