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 <gaumless@gmail.com>

Change-Id: I4f253194dae52897633ab5d96bb8c2964b8365d0
Reviewed-on: https://review.coreboot.org/c/coreboot/+/88332
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Matt DeVillier <matt.devillier@gmail.com>
This commit is contained in:
Martin Roth 2025-07-06 11:46:22 -06:00 committed by Matt DeVillier
commit 1219981177

View file

@ -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;