summaryrefslogtreecommitdiff
path: root/src/arch/x86/smbios.c
diff options
context:
space:
mode:
authorLijian Zhao <lijian.zhao@intel.com>2018-03-26 18:27:02 -0700
committerAaron Durbin <adurbin@chromium.org>2018-04-01 19:43:01 +0000
commitb1fc13ac9af0a74fc206991775933c19379058ba (patch)
tree4707c9e26da84209a0d8d3371c983ea18d4539bb /src/arch/x86/smbios.c
parentc2a9f0cf762a86ac0e52915f65fc514e13e6219a (diff)
downloadcoreboot-b1fc13ac9af0a74fc206991775933c19379058ba.tar.xz
arch/x86/smbios: Consider corner case of Part Number
In case of all DMI Type 17 to be empty, the strip trailing whitespace code will have a zero length Part Number entry, which will cause exception when using (len - 1) where len is zero. Add extra code to cover this corner case. BUG=b:76452395 TEST=Boot up fine with meowth platform, without this patch system will get stuck at "Create SMBIOS type 17". Change-Id: Id870c983584771dc1b60b1c99e95bbe7c0d25c4c Signed-off-by: Lijian Zhao <lijian.zhao@intel.com> Reviewed-on: https://review.coreboot.org/25377 Reviewed-by: Aaron Durbin <adurbin@chromium.org> Reviewed-by: Richard Spiegel <richard.spiegel@silverbackltd.com> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Diffstat (limited to 'src/arch/x86/smbios.c')
-rw-r--r--src/arch/x86/smbios.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/arch/x86/smbios.c b/src/arch/x86/smbios.c
index 70793741fa..7e776373c4 100644
--- a/src/arch/x86/smbios.c
+++ b/src/arch/x86/smbios.c
@@ -232,16 +232,19 @@ static void smbios_fill_dimm_part_number(const char *part_number,
len = strlen(trimmed_part_number);
invalid = 0; /* assume valid */
- for (i = 0; i < len - 1; i++) {
+ for (i = 0; i < len; i++) {
if (trimmed_part_number[i] < ' ') {
invalid = 1;
trimmed_part_number[i] = '*';
}
}
- if (invalid) {
+ if (len == 0) {
+ /* Null String in Part Number will have "None" instead. */
+ t->part_number = smbios_add_string(t->eos, "None");
+ } else if (invalid) {
char string_buffer[trimmed_buffer_size +
- 10 /* strlen("Invalid ()") */];
+ 10 /* strlen("Invalid ()") */];
snprintf(string_buffer, sizeof(string_buffer), "Invalid (%s)",
trimmed_part_number);