aboutsummaryrefslogtreecommitdiff
path: root/common/fdt_fixup.c
diff options
context:
space:
mode:
authorAndre Przywara <andre.przywara@arm.com>2020-10-07 11:09:42 +0100
committerAndre Przywara <andre.przywara@arm.com>2020-10-07 11:13:48 +0100
commit4276cfe2fa6fba6dc71a2cc3c0c2a5cc194ce542 (patch)
tree78537f07332c253c74385ae0da26e6af70d6e458 /common/fdt_fixup.c
parenteeb77da64684424ef275330e3e15d8350ecc1b07 (diff)
downloadtrusted-firmware-a-4276cfe2fa6fba6dc71a2cc3c0c2a5cc194ce542.tar.gz
fdt: Fix coverity complaint about 32-bit multiplication
Coverity raised an eyebrow over our GICR frame size calculation: ======== CID 362942: Integer handling issues (OVERFLOW_BEFORE_WIDEN) Potentially overflowing expression "nr_cores * gicr_frame_size" with type "unsigned int" (32 bits, unsigned) is evaluated using 32-bit arithmetic, and then used in a context that expects an expression of type "uint64_t" (64 bits, unsigned). ======== Even with a GICv4 (256KB frame size) we need 16384 cores to overflow 32-bit, so it's not a practical issue. But it's also easy to fix, so let's just do that: cast gicr_frame_size to an unsigned 64-bit integer, so that the multiplication is done in the 64-bit realm. Change-Id: Iad10e19b9e58d5fbf9d13205fbcef0aac5ae48af Signed-off-by: Andre Przywara <andre.przywara@arm.com>
Diffstat (limited to 'common/fdt_fixup.c')
-rw-r--r--common/fdt_fixup.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/common/fdt_fixup.c b/common/fdt_fixup.c
index a1604e74f7..e88a550080 100644
--- a/common/fdt_fixup.c
+++ b/common/fdt_fixup.c
@@ -425,7 +425,8 @@ int fdt_adjust_gic_redist(void *dtb, unsigned int nr_cores,
redist_size_32 = cpu_to_fdt32(nr_cores * gicr_frame_size);
val = &redist_size_32;
} else {
- redist_size_64 = cpu_to_fdt64(nr_cores * gicr_frame_size);
+ redist_size_64 = cpu_to_fdt64(nr_cores *
+ (uint64_t)gicr_frame_size);
val = &redist_size_64;
}