diff options
author | Arthur Heymans <arthur@aheymans.xyz> | 2024-09-04 14:41:42 +0200 |
---|---|---|
committer | Arthur Heymans <arthur@aheymans.xyz> | 2024-09-24 10:40:44 +0000 |
commit | 5d03b1d216558e4d2945b0fad290efb4ba3ac8b0 (patch) | |
tree | cee5c9c7ffb9a3ed4a01aba082a27fc246241bad /src/soc/intel/common/block | |
parent | 735ca7f24ad49d416ec7bd8f598e0cdbdf9ae0cc (diff) |
soc/intel/meminit: Check array size
Work around a GCC LTO bug. Even if no buffer overflow is bound to happen
as the soldered down path is taken GCC LTO complains about this.
Change-Id: Ib3d4ed8032bb06b6d08fbc2dc4b697df88745243
Signed-off-by: Arthur Heymans <arthur@aheymans.xyz>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/84205
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Subrata Banik <subratabanik@google.com>
Diffstat (limited to 'src/soc/intel/common/block')
-rw-r--r-- | src/soc/intel/common/block/memory/meminit.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/soc/intel/common/block/memory/meminit.c b/src/soc/intel/common/block/memory/meminit.c index f583213254..3c310798d0 100644 --- a/src/soc/intel/common/block/memory/meminit.c +++ b/src/soc/intel/common/block/memory/meminit.c @@ -115,8 +115,9 @@ static bool read_spd_dimm(FSPM_UPD *memupd, const struct soc_mem_cfg *soc_mem_cf for (ch = 0; ch < num_phys_ch; ch++) { for (dimm = 0; dimm < CONFIG_DIMMS_PER_CHANNEL; dimm++) { - blk.addr_map[CH_DIMM_OFFSET(ch, dimm)] = - info->smbus[ch].addr_dimm[dimm]; + if (CH_DIMM_OFFSET(ch, dimm) < ARRAY_SIZE(blk.addr_map)) + blk.addr_map[CH_DIMM_OFFSET(ch, dimm)] = + info->smbus[ch].addr_dimm[dimm]; } } @@ -167,6 +168,8 @@ static bool read_spd_dimm(FSPM_UPD *memupd, const struct soc_mem_cfg *soc_mem_cf size_t mrc_ch = soc_mem_cfg->phys_to_mrc_map[ch]; for (dimm = 0; dimm < CONFIG_DIMMS_PER_CHANNEL; dimm++) { + if (!(CH_DIMM_OFFSET(ch, dimm) < ARRAY_SIZE(blk.spd_array))) + continue; uint8_t *spd_data = blk.spd_array[CH_DIMM_OFFSET(ch, dimm)]; if (spd_data == NULL) continue; |