Usha P has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/36840 )
Change subject: soc/intel/skylake: Clean up report_cpu_info() function ......................................................................
soc/intel/skylake: Clean up report_cpu_info() function
This patch makes below clean up for report_cpu_info() function 1. Replace cpu_string with cpu_not_found 2. Assign default string "Platform info not available" to cpu_not_found string 3. Add array out of bound check while skiping leading white space in cpu brand string name
TEST=Able to build and boot soraka.
Change-Id: Idf7b04edc3fce147f7856591ce7e5a0cd05f43fe Signed-off-by: Usha P usha.p@intel.com --- M src/soc/intel/skylake/bootblock/report_platform.c 1 file changed, 5 insertions(+), 6 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/40/36840/1
diff --git a/src/soc/intel/skylake/bootblock/report_platform.c b/src/soc/intel/skylake/bootblock/report_platform.c index 0bd65c3..6eec951 100644 --- a/src/soc/intel/skylake/bootblock/report_platform.c +++ b/src/soc/intel/skylake/bootblock/report_platform.c @@ -166,7 +166,8 @@ { struct cpuid_result cpuidr; u32 i, index, cpu_id, cpu_feature_flag; - char cpu_string[50], *cpu_name = cpu_string; /* 48 bytes are reported */ + const char cpu_not_found[] = "Platform info not available"; + const char *cpu_name = cpu_not_found; int vt, txt, aes; msr_t microcode_ver; static const char *const mode[] = {"NOT ", ""}; @@ -174,10 +175,8 @@
index = 0x80000000; cpuidr = cpuid(index); - if (cpuidr.eax < 0x80000004) { - strcpy(cpu_string, "Platform info not available"); - } else { - u32 *p = (u32 *) cpu_string; + if (cpuidr.eax >= 0x80000004) { + u32 *p = (u32 *) cpu_not_found; for (i = 2; i <= 4; i++) { cpuidr = cpuid(index + i); *p++ = cpuidr.eax; @@ -187,7 +186,7 @@ } } /* Skip leading spaces in CPU name string */ - while (cpu_name[0] == ' ') + while (cpu_name[0] == ' ' && strlen(cpu_name) > 0) cpu_name++;
microcode_ver.lo = 0;