From b07c53d75c7fe5940c175ebd93cd675ea5d13c20 Mon Sep 17 00:00:00 2001 From: Yuji Sasaki Date: Fri, 22 Mar 2019 10:59:50 -0700 Subject: spi25: Debug flashrom crash when Write Protect is ON When hardware write protect is applied, flashrom crashed and generate coredump. spi_disable_blockprotect_generic() calls flash->chip->printlock() method when disable was failed, but this method is optional, can be NULL depends on type of flashrom chip. NULL pointer check before call is added to avoid crash. BRANCH=none BUG=b:129083894 TEST=Run on Mistral P2 (On CR50 console, run "wp disable") flashrom --wp-range 0 0x400000 flashrom --wp-enable (On CR50 console, run "wp enable") flashrom -r /tmp/test.bin Verify "Block protection could not be disabled!" is shown, but flash read completes. Signed-off-by: Yuji Sasaki Change-Id: I81094ab5f16a85871fc9869a2e285eddbbbdec4e Reviewed-on: https://chromium-review.googlesource.com/1535140 Commit-Ready: ChromeOS CL Exonerator Bot Tested-by: Edward O'Callaghan Reviewed-by: Stefan Reinauer Reviewed-by: SANTHOSH JANARDHANA HASSAN Reviewed-on: https://review.coreboot.org/c/flashrom/+/40468 Reviewed-by: Stefan Reinauer Tested-by: build bot (Jenkins) --- spi25_statusreg.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'spi25_statusreg.c') diff --git a/spi25_statusreg.c b/spi25_statusreg.c index 4b9b2a9b8..34f9ad4e1 100644 --- a/spi25_statusreg.c +++ b/spi25_statusreg.c @@ -168,7 +168,8 @@ static int spi_disable_blockprotect_generic(struct flashctx *flash, uint8_t bp_m status = spi_read_status_register(flash); if ((status & bp_mask) != 0) { msg_cerr("Block protection could not be disabled!\n"); - flash->chip->printlock(flash); + if (flash->chip->printlock) + flash->chip->printlock(flash); return 1; } msg_cdbg("disabled.\n"); -- cgit v1.2.3