summaryrefslogtreecommitdiffstats
path: root/ft2232_spi.c
diff options
context:
space:
mode:
authorCarl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>2009-07-14 10:26:56 +0000
committerCarl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>2009-07-14 10:26:56 +0000
commit35cc0620670673dc6670f352cc8112e64adc972c (patch)
treec286d89dadacecee2e68b84ce5606467e9ae33e8 /ft2232_spi.c
parent7e6320f4e232e757917d7399b1187f7b9bea5263 (diff)
downloadflashrom-35cc0620670673dc6670f352cc8112e64adc972c.zip
flashrom-35cc0620670673dc6670f352cc8112e64adc972c.tar.gz
Use a distinct return code for SPI commands with unsupported/invalid length
Some drivers support only a few combinations of read/write length and return error otherwise. Having a distinct return code for this error means we can handle it in upper layers. Corresponding to flashrom svn r653. Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net> Acked-by: Stefan Reinauer <stepan@coresystems.de>
Diffstat (limited to 'ft2232_spi.c')
-rw-r--r--ft2232_spi.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/ft2232_spi.c b/ft2232_spi.c
index 8e6e836..5d229b3 100644
--- a/ft2232_spi.c
+++ b/ft2232_spi.c
@@ -201,6 +201,9 @@ int ft2232_spi_send_command(unsigned int writecnt, unsigned int readcnt,
unsigned char port_val = 0;
int i, ret = 0;
+ if (writecnt > 65536 || readcnt > 65536)
+ return SPI_INVALID_LENGTH;
+
buf = realloc(buf, writecnt + readcnt + 100);
if (!buf) {
fprintf(stderr, "Out of memory!\n");
OpenPOWER on IntegriCloud