Avoid NULL deref in check_block_eraser()
spi_get_opcode_from_erasefn() can return NULL. It already prints a
proper error message, so we only have to propagate the error.
Change-Id: I7dbbb15c9364fcb505c3ff1b5f034185527483dc
Signed-off-by: Nico Huber <nico.h@gmx.de>
Reviewed-on: https://review.sourcearcade.org/c/flashprog/+/245
diff --git a/flashprog.c b/flashprog.c
index ec19f46..30e5668 100644
--- a/flashprog.c
+++ b/flashprog.c
@@ -833,6 +833,9 @@
int i;
const uint8_t *opcode = spi_get_opcode_from_erasefn(eraser.block_erase, &native_4ba);
+ if (!opcode)
+ return 1;
+
for (i = 0; opcode[i]; i++) {
if ((native_4ba && !spi_master_4ba(flash)) ||
!flash->mst.spi->probe_opcode(flash, opcode[i])) {