Edward O'Callaghan submitted this change.

View Change

Approvals: build bot (Jenkins): Verified Angel Pons: Looks good to me, approved Edward O'Callaghan: Looks good to me, approved
flashrom: initialize restore func count in correct place

Set `flash->chip_restore_fn_count` to zero before calling the chip's
unlock funciton in `prepare_flash_access()`.

Previously `flash->chip_restore_fn_count` was uninitialized before
calling `chip->unlock()` and subsequently reset after the dispatch by
initializing it. This caused the restore handler that is registered
within `spi_disable_blockprotect_generic()` to be lost.

BUG=b:228945411
BRANCH=none
TEST=enable wp; flashrom -w; check wp still enabled.

Change-Id: I4c7df424bd2ae2b5fb2a2ab6b47a3c9ff3233acf
Signed-off-by: Nikolai Artemiev <nartemiev@google.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/63881
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
---
M flashrom.c
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/flashrom.c b/flashrom.c
index 7f54488..8d6b3db 100644
--- a/flashrom.c
+++ b/flashrom.c
@@ -1825,6 +1825,9 @@
if (map_flash(flash) != 0)
return 1;

+ /* Initialize chip_restore_fn_count before chip unlock calls. */
+ flash->chip_restore_fn_count = 0;
+
/* Given the existence of read locks, we want to unlock for read,
erase and write. */
if (flash->chip->unlock)
@@ -1832,7 +1835,6 @@

flash->address_high_byte = -1;
flash->in_4ba_mode = false;
- flash->chip_restore_fn_count = 0;

/* Be careful about 4BA chips and broken masters */
if (flash->chip->total_size > 16 * 1024 && spi_master_no_4ba_modes(flash)) {

7 is the latest approved patch-set. No files were changed between the latest approved patch-set and the submitted one.

To view, visit change 63881. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: I4c7df424bd2ae2b5fb2a2ab6b47a3c9ff3233acf
Gerrit-Change-Number: 63881
Gerrit-PatchSet: 9
Gerrit-Owner: Nikolai Artemiev <nartemiev@google.com>
Gerrit-Reviewer: Angel Pons <th3fanbus@gmail.com>
Gerrit-Reviewer: Edward O'Callaghan <quasisec@chromium.org>
Gerrit-Reviewer: Nico Huber <nico.h@gmx.de>
Gerrit-Reviewer: build bot (Jenkins) <no-reply@coreboot.org>
Gerrit-CC: Paul Menzel <paulepanter@mailbox.org>
Gerrit-MessageType: merged