From 780b04e639976eabc784ac40f802ee0fc9275056 Mon Sep 17 00:00:00 2001 From: Reka Norman Date: Thu, 16 Sep 2021 10:12:31 +1000 Subject: util/spd_tools: Add max ID check for auto-generated IDs to part_id_gen Currently, the maximum part ID of 15 is enforced only for manually assigned IDs. Also enforce it for automatically assigned IDs. BUG=b:191776301 TEST=part_id_gen fails when the number of part IDs which would be assigned is greater than MaxMemoryId. Signed-off-by: Reka Norman Change-Id: I802190a13b68439ccbcdb28300ccc5fd1b38a9c9 Reviewed-on: https://review.coreboot.org/c/coreboot/+/57691 Tested-by: build bot (Jenkins) Reviewed-by: Furquan Shaikh Reviewed-by: Karthik Ramasubramanian --- util/spd_tools/src/part_id_gen/part_id_gen.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/util/spd_tools/src/part_id_gen/part_id_gen.go b/util/spd_tools/src/part_id_gen/part_id_gen.go index 3db2b6e8d9..7803361e48 100644 --- a/util/spd_tools/src/part_id_gen/part_id_gen.go +++ b/util/spd_tools/src/part_id_gen/part_id_gen.go @@ -240,6 +240,9 @@ func genPartIdInfo(parts []usedPart, partToSPDMap map[string]string, SPDToIndexM // Append new entry if index == -1 { index = len(partIdList) + if index > MaxMemoryId { + return nil, fmt.Errorf("Maximum part ID %d exceeded.", MaxMemoryId) + } partIdList = append(partIdList, partIds{}) } -- cgit v1.2.3