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
commit142e30fcaa1c3a63a1f0baf0b802ef888a0c250b (patch)
treec286d89dadacecee2e68b84ce5606467e9ae33e8 /ft2232_spi.c
parent78e4e127129398454813d1552b516638837c423e (diff)
downloadast2050-flashrom-142e30fcaa1c3a63a1f0baf0b802ef888a0c250b.zip
ast2050-flashrom-142e30fcaa1c3a63a1f0baf0b802ef888a0c250b.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