summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Reinauer <stefan.reinauer@coreboot.org>2014-04-26 16:12:55 +0000
committerStefan Tauner <stefan.tauner@alumni.tuwien.ac.at>2014-04-26 16:12:55 +0000
commit0b2d7e3493589760849df1e1b98fe471e28d5020 (patch)
tree40907ddf7d721ff6e1c55948357f5998db9c710d
parent2ba1b009c2572b72aca06e9d1c5ff3af9b95518a (diff)
downloadflashrom-0b2d7e3493589760849df1e1b98fe471e28d5020.zip
flashrom-0b2d7e3493589760849df1e1b98fe471e28d5020.tar.gz
CID1130000: Unchecked return value in default_spi_write_aai()
Also, try to always disable WRDI because else the user is stuck with a chip in AAI mode that won't return by itself w/o a reset. Corresponding to flashrom svn r1779. Signed-off-by: Stefan Reinauer <stefan.reinauer@coreboot.org> Signed-off-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at> Acked-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at>
-rw-r--r--spi25.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/spi25.c b/spi25.c
index e001196..69be073 100644
--- a/spi25.c
+++ b/spi25.c
@@ -1128,13 +1128,9 @@ int default_spi_write_aai(struct flashctx *flash, uint8_t *buf, unsigned int sta
result = spi_send_multicommand(flash, cmds);
- if (result) {
- msg_cerr("%s failed during start command execution\n",
- __func__);
- /* FIXME: Should we send WRDI here as well to make sure the chip
- * is not in AAI mode?
- */
- return result;
+ if (result != 0) {
+ msg_cerr("%s failed during start command execution: %d\n", __func__, result);
+ goto bailout;
}
while (spi_read_status_register(flash) & SPI_SR_WIP)
programmer_delay(10);
@@ -1146,8 +1142,11 @@ int default_spi_write_aai(struct flashctx *flash, uint8_t *buf, unsigned int sta
while (pos < start + len - 1) {
cmd[1] = buf[pos++ - start];
cmd[2] = buf[pos++ - start];
- spi_send_command(flash, JEDEC_AAI_WORD_PROGRAM_CONT_OUTSIZE, 0,
- cmd, NULL);
+ result = spi_send_command(flash, JEDEC_AAI_WORD_PROGRAM_CONT_OUTSIZE, 0, cmd, NULL);
+ if (result != 0) {
+ msg_cerr("%s failed during followup AAI command execution: %d\n", __func__, result);
+ goto bailout;
+ }
while (spi_read_status_register(flash) & SPI_SR_WIP)
programmer_delay(10);
}
@@ -1165,4 +1164,8 @@ int default_spi_write_aai(struct flashctx *flash, uint8_t *buf, unsigned int sta
}
return 0;
+
+bailout:
+ spi_write_disable(flash);
+ return SPI_GENERIC_ERROR;
}
OpenPOWER on IntegriCloud