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 <rekanorman@google.com>
Change-Id: I802190a13b68439ccbcdb28300ccc5fd1b38a9c9
Reviewed-on: https://review.coreboot.org/c/coreboot/+/57691
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Furquan Shaikh <furquan@google.com>
Reviewed-by: Karthik Ramasubramanian <kramasub@google.com>
This commit is contained in:
Reka Norman 2021-09-16 10:12:31 +10:00 committed by Furquan Shaikh
parent c9686d22b1
commit 780b04e639
1 changed files with 3 additions and 0 deletions

View File

@ -240,6 +240,9 @@ func genPartIdInfo(parts []usedPart, partToSPDMap map[string]string, SPDToIndexM
// Append new entry // Append new entry
if index == -1 { if index == -1 {
index = len(partIdList) index = len(partIdList)
if index > MaxMemoryId {
return nil, fmt.Errorf("Maximum part ID %d exceeded.", MaxMemoryId)
}
partIdList = append(partIdList, partIds{}) partIdList = append(partIdList, partIds{})
} }