summaryrefslogtreecommitdiffstats
path: root/flashrom.c
diff options
context:
space:
mode:
authorPeter Stuge <peter@stuge.se>2008-04-28 14:47:30 +0000
committerPeter Stuge <peter@stuge.se>2008-04-28 14:47:30 +0000
commitf31104cf3b63a058b63f8b9aed89c1901d5d9acd (patch)
tree4aad4a51dd58a634205bd40b7dae1ba93d4717b5 /flashrom.c
parentef300238b649b9a7229bb68c70690faa82b2d18d (diff)
downloadast2050-flashrom-f31104cf3b63a058b63f8b9aed89c1901d5d9acd.zip
ast2050-flashrom-f31104cf3b63a058b63f8b9aed89c1901d5d9acd.tar.gz
Handle NULL probe, erase and write function pointers in the flashchips table
The read pointer was already checked properly. Corresponding to flashrom svn r218 and coreboot v2 svn r3273. Signed-off-by: Peter Stuge <peter@stuge.se> Acked-by: Stefan Reinauer <stepan@coresystems.de>
Diffstat (limited to 'flashrom.c')
-rw-r--r--flashrom.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/flashrom.c b/flashrom.c
index 29c3a58..c7d0bda 100644
--- a/flashrom.c
+++ b/flashrom.c
@@ -111,6 +111,11 @@ struct flashchip *probe_flash(struct flashchip *flash)
}
printf_debug("Probing for %s %s, %d KB: ",
flash->vendor, flash->name, flash->total_size);
+ if (!flash->probe) {
+ printf_debug("failed! flashrom has no probe function for this flash chip.\n");
+ flash++;
+ continue;
+ }
size = flash->total_size * 1024;
@@ -425,6 +430,10 @@ int main(int argc, char *argv[])
if (erase_it) {
printf("Erasing flash chip\n");
+ if (!flash->erase) {
+ fprintf(stderr, "Error: flashrom has no erase function for this flash chip.\n");
+ return 1;
+ }
flash->erase(flash);
exit(0);
} else if (read_it) {
@@ -493,8 +502,13 @@ int main(int argc, char *argv[])
// ////////////////////////////////////////////////////////////
- if (write_it)
+ if (write_it) {
+ if (!flash->write) {
+ fprintf(stderr, "Error: flashrom has no write function for this flash chip.\n");
+ return 1;
+ }
ret |= flash->write(flash, buf);
+ }
if (verify_it)
ret |= verify_flash(flash, buf);
OpenPOWER on IntegriCloud