From 12199811776efb1ce9db100c1a7f4652491ca634 Mon Sep 17 00:00:00 2001 From: Martin Roth Date: Sun, 6 Jul 2025 11:46:22 -0600 Subject: [PATCH] drivers/emu/qemu: Add a comment about fw_cfg assumptions This documents that if the fw_cfg table was improperly configured by QEMU, the fw_cfg_smbios_init() function would leak memory. We could add a check to verify that this doesn't happen, but honestly that seems like overkill. This just documents the issue in case this code is copied for use elsewhere. BUG=CIDs 1405799, 1405791, 1405792, 1405796, 1405797 Signed-off-by: Martin Roth Change-Id: I4f253194dae52897633ab5d96bb8c2964b8365d0 Reviewed-on: https://review.coreboot.org/c/coreboot/+/88332 Tested-by: build bot (Jenkins) Reviewed-by: Matt DeVillier --- src/drivers/emulation/qemu/fw_cfg.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/drivers/emulation/qemu/fw_cfg.c b/src/drivers/emulation/qemu/fw_cfg.c index 3725419e7b..98f2a7b94d 100644 --- a/src/drivers/emulation/qemu/fw_cfg.c +++ b/src/drivers/emulation/qemu/fw_cfg.c @@ -351,6 +351,12 @@ static const char *type1_serial_number; static const char *type1_family; static u8 type1_uuid[16]; +/* + * We're making an assumption that the table we get from fw_cfg_get() & + * fw_cfg_read() only has one entry for each of the above fields. If + * there's more than one, we would leak the memory created by strdup() + * for the previous iterations through the loop. + */ static void fw_cfg_smbios_init(void) { static int done = 0;