spd: remove trailing whitespaces on DMI 17 part number.

CL:980153 introduced to remove trailing whitespaces of DMI 17 part
number in firmware level then CL:993764 added the support to strip off
trailing whitespaces of part number from SPD as well; otherwise the
comparison will get failed between part number in SMBIOS and SPD.

On the other hand, legacy firmware branches  without CL:980153 would still have
trailing whitespaces if there are. As a result, it always can't be matched in
the mosys.

The solution here is always to remove whitesapces on DMI 17
part number in order to guarantee the compatibility different firmware

TEST=manually test on the DUT.
Change-Id: If49f74870deec73f424f153d1477530fb8d585a4
Reviewed-on: https://chromium-review.googlesource.com/1379991
Commit-Ready: Marco Chen <marcochen@chromium.org>
Tested-by: Marco Chen <marcochen@chromium.org>
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Reviewed-by: Furquan Shaikh <furquan@chromium.org>
(cherry picked from commit 4983d6ec3547276ce23a7a0e35bdec371116e92e)
Reviewed-on: https://chromium-review.googlesource.com/c/1395898
Reviewed-by: Marco Chen <marcochen@chromium.org>
Commit-Queue: Marco Chen <marcochen@chromium.org>
diff --git a/lib/spd/spd.c b/lib/spd/spd.c
index a097b05..007c722 100644
--- a/lib/spd/spd.c
+++ b/lib/spd/spd.c
@@ -294,6 +294,13 @@
 		goto out;
+	// Legacy firmware doesn't remove trailing whitespaces from SPD part
+	// number so needs to check again; otherwise the part number might never
+	// matches to spd_part_num[] below which did remove trailing whitespaces.
+	while (smbios_part_num_len > 0 &&
+	       smbios_part_num[smbios_part_num_len - 1] == ' ')
+		smbios_part_num_len--;
 	num_spd = spd_file_len / info->spd_len;
 	for (i = 0; i < num_spd; i++) {