libpayload/drivers: Fix mem-leak in cbmem_console error condition

When returning from cbmem_console_snapshot() because of a corrupted
console structure, the memory that was just allocated was not being
freed as it "should be".

BUG=CID 1419477

Signed-off-by: Martin Roth <gaumless@gmail.com>
Change-Id: I85370fb49c9ef9a00cd2ea516fa80c9e152c9b48
Reviewed-on: https://review.coreboot.org/c/coreboot/+/88334
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Elyes Haouas <ehaouas@noos.fr>
This commit is contained in:
Martin Roth 2025-07-06 11:56:03 -06:00 committed by Matt DeVillier
commit 05396238da

View file

@ -126,6 +126,7 @@ char *cbmem_console_snapshot(void)
if (overflow) {
if (cursor >= size) {
printf("ERROR: CBMEM console struct is corrupted\n");
free(console_c);
return NULL;
}
for (oldc = cursor; oldc < size; oldc++)