Nico Huber merged this change.

View Change

Approvals: build bot (Jenkins): Verified David Hendricks: Looks good to me, approved
spi25_statusreg: Return defined value on failed RDSR

The interface of spi_read_status_register() is broken and can't return
errors. Let's not return random stack data at least.

Change-Id: I714b20001a5443bba665c2e0061ca14069777581
Signed-off-by: Nico Huber <nico.h@gmx.de>
Reviewed-on: https://review.coreboot.org/22017
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: David Hendricks <david.hendricks@gmail.com>
---
M spi25_statusreg.c
1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/spi25_statusreg.c b/spi25_statusreg.c
index 01a6862..05c7acf 100644
--- a/spi25_statusreg.c
+++ b/spi25_statusreg.c
@@ -117,8 +117,11 @@

/* Read Status Register */
ret = spi_send_command(flash, sizeof(cmd), sizeof(readarr), cmd, readarr);
- if (ret)
+ if (ret) {
msg_cerr("RDSR failed!\n");
+ /* FIXME: We should propagate the error. */
+ return 0;
+ }

return readarr[0];
}

To view, visit change 22017. To unsubscribe, visit settings.

Gerrit-Project: flashrom
Gerrit-Branch: staging
Gerrit-MessageType: merged
Gerrit-Change-Id: I714b20001a5443bba665c2e0061ca14069777581
Gerrit-Change-Number: 22017
Gerrit-PatchSet: 2
Gerrit-Owner: Nico Huber <nico.h@gmx.de>
Gerrit-Reviewer: David Hendricks <david.hendricks@gmail.com>
Gerrit-Reviewer: Nico Huber <nico.h@gmx.de>
Gerrit-Reviewer: Paul Menzel <paulepanter@users.sourceforge.net>
Gerrit-Reviewer: build bot (Jenkins) <no-reply@coreboot.org>