mb/google/poppy/var/nami: Ensure SPD index is non-zero

Memory id's are 1-indexed for DDR4, so we need to check that the SPD
index is non-zero before converting it to the 0-indexed value in the
bitmap.

Change-Id: Icc542239d91c39b89c23f31856c28e7c20b2fc4d
Signed-off-by: Jacob Garber <jgarber1@ualberta.ca>
Found-by: Coverity CID 1387028
Reviewed-on: https://review.coreboot.org/c/coreboot/+/33183
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
This commit is contained in:
Jacob Garber 2019-06-03 17:17:11 -06:00 committed by Martin Roth
parent 8cf8a6375e
commit fb5a83df3c
1 changed files with 5 additions and 1 deletions

View File

@ -66,8 +66,12 @@ static void fill_ddr4_memory_params(struct memory_params *p)
p->type = MEMORY_DDR4;
p->use_sec_spd = 0;
int spd_index = variant_memory_sku();
if (spd_index == 0)
die("SPD index is 0\n");
/* Rcomp resistor values are different for SDP and DDP. */
if (ddp_bitmap & MEM_ID(variant_memory_sku())) {
if (ddp_bitmap & MEM_ID(spd_index)) {
p->rcomp_resistor = rcomp_resistor_ddp;
p->rcomp_resistor_size = sizeof(rcomp_resistor_ddp);
} else {