mb/google/cyan/spd/spd.c: Fix module part number transfer

With the increase of dimm->module_part_number size from 19 to 21 (commit
35b273eea3) "include/memory_info.h: Change part number field from 19 bytes
to 21", this code is now advancing outside DDR3 SPD designated space. The
correct size is already defined as LPDDR3_SPD_PART_LEN, use it. Also make
sure to 0 terminate the string.

BUG=b:77943312
TEST=Build cyan.

Change-Id: Iba0ef4149acfc09b7672fce079df06bf1a01dff6
Signed-off-by: Richard Spiegel <richard.spiegel@silverbackltd.com>
Reviewed-on: https://review.coreboot.org/25702
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Martin Roth <martinroth@google.com>
Reviewed-by: Raul Rangel <rrangel@chromium.org>
Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net>
This commit is contained in:
Richard Spiegel 2018-04-17 10:09:17 -07:00 committed by Martin Roth
parent ed76908e4a
commit 90b3095093
1 changed files with 3 additions and 2 deletions

View File

@ -145,8 +145,9 @@ static void set_dimm_info(uint8_t *spd, struct dimm_info *dimm)
}
dimm->dimm_size = capmb / 8 * busw / devw * ranks; /* MiB */
dimm->mod_type = spd[3] & 0xf;
memcpy((char *)&dimm->module_part_number[0], &spd[0x80],
sizeof(dimm->module_part_number) - 1);
strncpy((char *)&dimm->module_part_number[0], (char *)&spd[0x80],
LPDDR3_SPD_PART_LEN);
dimm->module_part_number[LPDDR3_SPD_PART_LEN] = 0;
dimm->mod_id = *(uint16_t *)&spd[0x94];
switch (busw) {