Lijian Zhao has uploaded this change for review. ( https://review.coreboot.org/25377
Change subject: arch/x86/smbios: Consider conner case of Part Number ......................................................................
arch/x86/smbios: Consider conner case of Part Number
In case of all DMI Type 17 could be all 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=None TEST=Boot up fine with moowth platform, without this patch system will stuck at "Create SMBIOS type 17".
Change-Id: Id870c983584771dc1b60b1c99e95bbe7c0d25c4c Signed-off-by: Lijian Zhao lijian.zhao@intel.com --- M src/arch/x86/smbios.c 1 file changed, 8 insertions(+), 4 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/77/25377/1
diff --git a/src/arch/x86/smbios.c b/src/arch/x86/smbios.c index 7079374..c14c231 100644 --- a/src/arch/x86/smbios.c +++ b/src/arch/x86/smbios.c @@ -232,10 +232,14 @@ len = strlen(trimmed_part_number);
invalid = 0; /* assume valid */ - for (i = 0; i < len - 1; i++) { - if (trimmed_part_number[i] < ' ') { - invalid = 1; - trimmed_part_number[i] = '*'; + if (len == 0) + invalid = 1; + else { + for (i = 0; i < len - 1; i++) { + if (trimmed_part_number[i] < ' ') { + invalid = 1; + trimmed_part_number[i] = '*'; + } } }