From 4427a34b6bcfc7f812edf19b9cdba566e98bc691 Mon Sep 17 00:00:00 2001 From: Pranava Y N Date: Sun, 18 Jan 2026 21:35:57 +0530 Subject: [PATCH] drivers/intel/fsp2_0: Fix string length handling in timestamp printing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The current implementation uses '%*s' which treats the calculated str_len as a minimum field width. If the underlying string buffer is not null-terminated, printk will continue reading past the buffer until it encounters a null byte. Switch to '%.*s' to correctly use the precision field, which specifies the maximum number of characters to be printed from the string. BUG=None TEST=Able to dump FSP performance data with `DISPLAY_FSP_TIMESTAMPS` Kconfig selected and meeting the FSP prerequisites. Verify that the performance data table is printed correctly. ``` [INFO ] +---------------------------------------------------+ [INFO ] |------ FSP Performance Timestamp Table Dump -------| [INFO ] +---------------------------------------------------+ [INFO ] | Perf-ID Timestamp(us) String/GUID | [INFO ] +---------------------------------------------------+ [INFO ] 0 1242275 SEC/52c05b14-0b98-496c-bc3b04b50211d680 [INFO ] 50 1242282 PEI/52c05b14-0b98-496c-bc3b04b50211d680 [INFO ] 40 1242284 PreMem/52c05b14-0b98-496c-bc3b04b50211d680 ``` Change-Id: Id95bd34b9c7d45d2c363339eb18adc5ac731c72b Signed-off-by: Pranava Y N Reviewed-on: https://review.coreboot.org/c/coreboot/+/90788 Tested-by: build bot (Jenkins) Reviewed-by: Paul Menzel Reviewed-by: Kapil Porwal Reviewed-by: Subrata Banik Reviewed-by: Jérémy Compostella --- src/drivers/intel/fsp2_0/fsp_timestamp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/drivers/intel/fsp2_0/fsp_timestamp.c b/src/drivers/intel/fsp2_0/fsp_timestamp.c index 872cf9149e..65a6060f57 100644 --- a/src/drivers/intel/fsp2_0/fsp_timestamp.c +++ b/src/drivers/intel/fsp2_0/fsp_timestamp.c @@ -51,7 +51,7 @@ static void print_guid_record(const struct generic_event_record *rec) static void print_string_record(const struct generic_event_record *rec) { size_t str_len = rec->header.length - offsetof(struct generic_event_record, string); - printk(BIOS_INFO, "%5x\t%16llu\t\t%*s/", + printk(BIOS_INFO, "%5x\t%16llu\t\t%.*s/", rec->progress_id, TIMESTAMP_TO_MICRO(rec->timestamp), (int)str_len, rec->string); fsp_print_guid(BIOS_INFO, rec->guid); printk(BIOS_INFO, "\n");