From c19140b49f1972cb3b0be5467a4c8a735226bb90 Mon Sep 17 00:00:00 2001 From: Rob Barnes Date: Fri, 14 Aug 2020 15:25:33 -0600 Subject: util: Add check for duplicate entries in mem parts json Check for duplicate entries in mem parts json file. BUG=b:162939176 TEST=Verified that tool throws error when there is a duplicate. Signed-off-by: Rob Barnes Change-Id: I7c638c7938958727cfc832e7b4556acbc04b0ca4 Reviewed-on: https://review.coreboot.org/c/coreboot/+/44478 Reviewed-by: Furquan Shaikh Tested-by: build bot (Jenkins) --- util/spd_tools/ddr4/gen_spd.go | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'util/spd_tools') diff --git a/util/spd_tools/ddr4/gen_spd.go b/util/spd_tools/ddr4/gen_spd.go index 831cddf824..e99239acd2 100644 --- a/util/spd_tools/ddr4/gen_spd.go +++ b/util/spd_tools/ddr4/gen_spd.go @@ -1068,7 +1068,14 @@ func verifySupportedCASLatencies(part *memPart) error { } func validateMemoryParts(memParts *memParts) error { + memPartExists := make(map[string]bool) + for i := 0; i < len(memParts.MemParts); i++ { + if memPartExists[memParts.MemParts[i].Name] { + return fmt.Errorf(memParts.MemParts[i].Name + " is duplicated in mem_parts_list_json") + } + memPartExists[memParts.MemParts[i].Name] = true + if err := validateSpeedMTps(memParts.MemParts[i].Attribs.SpeedMTps); err != nil { return err } -- cgit v1.2.3