Patrick Georgi has uploaded this change for review. ( https://review.coreboot.org/c/flashrom/+/40970 )
Change subject: spi95: Check for success before using send_command's returned data ......................................................................
spi95: Check for success before using send_command's returned data
If the transfer failed, the data might be invalid.
Change-Id: I3ad9daa00a54e2a3954983cec91b6685f1a98880 Found-By: Coverity Scan #1405870 Signed-off-by: Patrick Georgi pgeorgi@google.com --- M spi95.c 1 file changed, 4 insertions(+), 1 deletion(-)
git pull ssh://review.coreboot.org:29418/flashrom refs/changes/70/40970/1
diff --git a/spi95.c b/spi95.c index ecb2c1d..976f99a 100644 --- a/spi95.c +++ b/spi95.c @@ -33,12 +33,15 @@ static const unsigned char cmd[ST_M95_RDID_OUTSIZE_MAX] = { ST_M95_RDID }; unsigned char readarr[ST_M95_RDID_INSIZE]; uint32_t id1, id2; + int ret;
uint32_t rdid_outsize = ST_M95_RDID_2BA_OUTSIZE; // 16 bit address if (flash->chip->total_size * KiB > 64 * KiB) rdid_outsize = ST_M95_RDID_3BA_OUTSIZE; // 24 bit address
- spi_send_command(flash, rdid_outsize, sizeof(readarr), cmd, readarr); + ret = spi_send_command(flash, rdid_outsize, sizeof(readarr), cmd, readarr); + if (ret) + return ret;
id1 = readarr[0]; // manufacture id id2 = (readarr[1] << 8) | readarr[2]; // SPI family code + model id
Angel Pons has posted comments on this change. ( https://review.coreboot.org/c/flashrom/+/40970 )
Change subject: spi95: Check for success before using send_command's returned data ......................................................................
Patch Set 1: Code-Review+2
Patrick Georgi has submitted this change. ( https://review.coreboot.org/c/flashrom/+/40970 )
Change subject: spi95: Check for success before using send_command's returned data ......................................................................
spi95: Check for success before using send_command's returned data
If the transfer failed, the data might be invalid.
Change-Id: I3ad9daa00a54e2a3954983cec91b6685f1a98880 Found-By: Coverity Scan #1405870 Signed-off-by: Patrick Georgi pgeorgi@google.com Reviewed-on: https://review.coreboot.org/c/flashrom/+/40970 Tested-by: build bot (Jenkins) no-reply@coreboot.org Reviewed-by: Angel Pons th3fanbus@gmail.com --- M spi95.c 1 file changed, 4 insertions(+), 1 deletion(-)
Approvals: build bot (Jenkins): Verified Angel Pons: Looks good to me, approved
diff --git a/spi95.c b/spi95.c index ecb2c1d..976f99a 100644 --- a/spi95.c +++ b/spi95.c @@ -33,12 +33,15 @@ static const unsigned char cmd[ST_M95_RDID_OUTSIZE_MAX] = { ST_M95_RDID }; unsigned char readarr[ST_M95_RDID_INSIZE]; uint32_t id1, id2; + int ret;
uint32_t rdid_outsize = ST_M95_RDID_2BA_OUTSIZE; // 16 bit address if (flash->chip->total_size * KiB > 64 * KiB) rdid_outsize = ST_M95_RDID_3BA_OUTSIZE; // 24 bit address
- spi_send_command(flash, rdid_outsize, sizeof(readarr), cmd, readarr); + ret = spi_send_command(flash, rdid_outsize, sizeof(readarr), cmd, readarr); + if (ret) + return ret;
id1 = readarr[0]; // manufacture id id2 = (readarr[1] << 8) | readarr[2]; // SPI family code + model id