From 6b1f3b084147a09a90ecb3efea88e3c80113e0ca Mon Sep 17 00:00:00 2001 From: Angel Pons Date: Tue, 25 May 2021 12:46:43 +0200 Subject: dummyflasher.c: Don't leak `emu_persistent_image` Ensure `emu_persistent_image` doesn't end up leaking memory. Change-Id: I76529973cefcc6a1472681e1f4da8239fcbf07a6 Signed-off-by: Angel Pons Reviewed-on: https://review.coreboot.org/c/flashrom/+/54905 Tested-by: build bot (Jenkins) Reviewed-by: Edward O'Callaghan --- dummyflasher.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/dummyflasher.c b/dummyflasher.c index 325263dd..717f8d11 100644 --- a/dummyflasher.c +++ b/dummyflasher.c @@ -634,9 +634,8 @@ static int dummy_shutdown(void *data) write_buf_to_file(emu_data->flashchip_contents, emu_data->emu_chip_size, emu_data->emu_persistent_image); - free(emu_data->emu_persistent_image); - emu_data->emu_persistent_image = NULL; } + free(emu_data->emu_persistent_image); free(emu_data->flashchip_contents); } #endif @@ -1001,6 +1000,7 @@ int dummy_init(void) if (read_buf_from_file(data->flashchip_contents, data->emu_chip_size, data->emu_persistent_image)) { msg_perr("Unable to read %s\n", data->emu_persistent_image); + free(data->emu_persistent_image); free(data->flashchip_contents); return 1; } @@ -1012,6 +1012,7 @@ int dummy_init(void) dummy_init_out: if (register_shutdown(dummy_shutdown, data)) { + free(data->emu_persistent_image); free(data->flashchip_contents); free(data); return 1; -- cgit v1.2.3