Browse Source

fix(el3-spmc): fix incorrect CASSERT

Check that the size of desc->emad_count is 4, not that sizeof(int) is
nonzero.  Also improve a comment.

Change-Id: I8bf69b637158ddffe2d08aed3d9879a4d7fd3514
Signed-off-by: Demi Marie Obenour <demiobenour@gmail.com>
pull/2000/head
Demi Marie Obenour 1 year ago
committed by Olivier Deprez
parent
commit
1dd79f9e23
  1. 6
      services/std_svc/spm/el3_spmc/spmc_shared_mem.c

6
services/std_svc/spm/el3_spmc/spmc_shared_mem.c

@ -743,10 +743,12 @@ spmc_validate_mtd_start(struct ffa_mtd *desc, uint32_t ffa_version,
/*
* Overflow is impossible: the arithmetic happens in at least 64-bit
* precision, but all of the operands are bounded by UINT32_MAX, and
* ((2^32 - 1)^2 + (2^32 - 1) + (2^32 - 1)) = ((2^32 - 1) * (2^32 + 1))
* ((2^32 - 1) * (2^32 - 1) + (2^32 - 1) + (2^32 - 1))
* = ((2^32 - 1) * ((2^32 - 1) + 1 + 1))
* = ((2^32 - 1) * (2^32 + 1))
* = (2^64 - 1).
*/
CASSERT(sizeof(desc->emad_count == 4), assert_emad_count_max_too_large);
CASSERT(sizeof(desc->emad_count) == 4, assert_emad_count_max_too_large);
emad_end = (desc->emad_count * (unsigned long long)emad_size) +
(unsigned long long)sizeof(struct ffa_comp_mrd) +
(unsigned long long)emad_offset;

Loading…
Cancel
Save