From 8e0bfee62fce575e436f31f21502bb9de8eb1dec Mon Sep 17 00:00:00 2001 From: Anastasia Klimchuk Date: Mon, 27 Oct 2025 08:47:52 +1100 Subject: [PATCH] Revert "flashrom.c: move `can_change_target_regions` check below wp unlock" This reverts commit 3a6d88f4385886298ae0362ee8543725599fdd80. Reason: tests fail [ FAILED ] erase failure for unskipped unwritable regions [ ERROR ] --- Blocks allocated... ../libflashrom.c:631: note: block 0x55ede27e51e0 allocated here ERROR: erase failure for unskipped unwritable regions leaked 1 block(s) [ FAILED ] full_chip_erase_with_wp_dummyflasher_test_success [ ERROR ] --- Blocks allocated... ../libflashrom.c:631: note: block 0x55ede27e3800 allocated here ../spi25_statusreg.c:312: note: block 0x55ede27e7380 allocated here ERROR: full_chip_erase_with_wp_dummyflasher_test_success leaked 2 block(s) Change-Id: I912dab51f7a471d098f6f265aa2582f4194b7b6b Signed-off-by: Anastasia Klimchuk Reviewed-on: https://review.coreboot.org/c/flashrom/+/89753 Tested-by: build bot (Jenkins) Reviewed-by: Stefan Reinauer Reviewed-by: Peter Marheine --- flashrom.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/flashrom.c b/flashrom.c index b6f52fa55..100fc480a 100644 --- a/flashrom.c +++ b/flashrom.c @@ -1900,6 +1900,13 @@ int prepare_flash_access(struct flashctx *const flash, return 1; } + if ((write_it || erase_it) && !flash->flags.force) { + if (!can_change_target_regions(flash)) { + msg_cerr("At least one target region is not fully writable. Aborting.\n"); + return 1; + } + } + if (map_flash(flash) != 0) return 1; @@ -1923,13 +1930,6 @@ int prepare_flash_access(struct flashctx *const flash, if (ret && bp_func) bp_func(flash); - if ((write_it || erase_it) && !flash->flags.force) { - if (!can_change_target_regions(flash)) { - msg_cerr("At least one target region is not fully writable. Aborting.\n"); - return 1; - } - } - flash->address_high_byte = -1; flash->in_4ba_mode = false;