From bb0ab9e5319254f768d54f5f8feecd453fe1181f Mon Sep 17 00:00:00 2001 From: Nico Huber Date: Thu, 13 Sep 2018 10:49:54 +0200 Subject: device/ddr3: Prevent overflow when adding SMBUS Table 17 entries Change-Id: If84c6849011106b2a50e504b79cda9cd6a3a9cc3 Signed-off-by: Nico Huber Reviewed-on: https://review.coreboot.org/28588 Tested-by: build bot (Jenkins) Reviewed-by: Patrick Rudolph --- src/device/dram/ddr3.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/device') diff --git a/src/device/dram/ddr3.c b/src/device/dram/ddr3.c index 63ca964a5a..f27fdcb1e0 100644 --- a/src/device/dram/ddr3.c +++ b/src/device/dram/ddr3.c @@ -559,6 +559,12 @@ enum cb_err spd_add_smbios17(const u8 channel, const u8 slot, memset(mem_info, 0, sizeof(*mem_info)); } + if (mem_info->dimm_cnt >= ARRAY_SIZE(mem_info->dimm)) { + printk(BIOS_WARNING, "BUG: Too many DIMM infos for %s.\n", + __func__); + return CB_ERR; + } + dimm = &mem_info->dimm[mem_info->dimm_cnt]; if (info->size_mb) { dimm->ddr_type = MEMORY_TYPE_DDR3; -- cgit v1.2.3