soc/mediatek: Fix printing SPM version

Currently the SPM version string is stored at the end of the blob,
possibly without a trailing '\0'. Therefore, we should be careful not to
print characters beyond the blob size.

BUG=b:211944565
TEST=emerge-corsola coreboot
TEST=SPM version looked good in AP console
BRANCH=asurada,cherry

Change-Id: Icfeb686539dc20cf5b78de77c27bdbb137b5d624
Signed-off-by: Yu-Ping Wu <yupingso@chromium.org>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/61800
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Hung-Te Lin <hungte@chromium.org>
This commit is contained in:
Yu-Ping Wu 2022-02-10 17:27:57 +08:00 committed by Felix Held
parent b0844490db
commit 2fdcb64ec9

View File

@ -50,5 +50,7 @@ void spm_parse_firmware(struct mtk_mcu *mcu)
/* Version */
offset += copy_size;
assert(offset < file_size);
printk(BIOS_INFO, "SPM: spmfw (version %s)\n", (u8 *)mcu->load_buffer + offset);
printk(BIOS_INFO, "SPM: spmfw (version %.*s)\n",
(int)(file_size - offset),
(u8 *)mcu->load_buffer + offset);
}