1
0
mirror of https://review.coreboot.org/flashrom.git synced 2025-11-14 03:30:41 +01:00

flashrom.c: use finalize_flash_access in case of failure

`unlock_flash_wp` which is called in `prepare_flash_access` registers
chip restore via `register_chip_restore`. Function failing after
this moment would result in memory leak.

Fix this issue by calling `finalize_flash_access` even if this function
fails.

Change-Id: I2e7be3f4f71447a1df532f02d1e45d20c253da5a
Signed-off-by: Michał Iwanicki <michal.iwanicki@3mdeb.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/89684
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
This commit is contained in:
Michał Iwanicki
2025-10-22 10:02:06 +02:00
committed by Anastasia Klimchuk
parent d867ef7256
commit cb19a53db0

View File

@@ -1970,6 +1970,7 @@ int flashrom_flash_erase(struct flashctx *const flashctx)
msg_gerr("Error: some of the required checks to prepare flash access failed. "
"Earlier messages should give more details.\n"
"Erase operation has not started.\n");
finalize_flash_access(flashctx);
return ERROR_FLASHROM_PREPARE_FLASH_ACCESS;
}
@@ -2081,7 +2082,7 @@ int flashrom_image_write(struct flashctx *const flashctx, void *const buffer, co
msg_gerr("Error: some of the required checks to prepare flash access failed. "
"Earlier messages should give more details.\n"
"Write operation has not started.\n");
goto _free_ret;
goto _finalize_ret;
}
/* If given, assume flash chip contains same data as `refcontents`. */