aboutsummaryrefslogtreecommitdiffstats
path: root/dediprog.c
diff options
context:
space:
mode:
Diffstat (limited to 'dediprog.c')
-rw-r--r--dediprog.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/dediprog.c b/dediprog.c
index 58f1d434..72818ea9 100644
--- a/dediprog.c
+++ b/dediprog.c
@@ -412,15 +412,15 @@ static int dediprog_spi_bulk_read(struct flashctx *flash, uint8_t *buf, unsigned
struct libusb_transfer *transfers[DEDIPROG_ASYNC_TRANSFERS] = { NULL, };
struct libusb_transfer *transfer;
+ if (len == 0)
+ return 0;
+
if ((start % chunksize) || (len % chunksize)) {
msg_perr("%s: Unaligned start=%i, len=%i! Please report a bug at flashrom@flashrom.org\n",
__func__, start, len);
return 1;
}
- if (len == 0)
- return 0;
-
int command_packet_size;
switch (protocol()) {
case PROTOCOL_V1:
@@ -504,7 +504,7 @@ static int dediprog_spi_read(struct flashctx *flash, uint8_t *buf, unsigned int
int ret;
/* chunksize must be 512, other sizes will NOT work at all. */
const unsigned int chunksize = 0x200;
- unsigned int residue = start % chunksize ? chunksize - start % chunksize : 0;
+ unsigned int residue = start % chunksize ? min(len, chunksize - start % chunksize) : 0;
unsigned int bulklen;
dediprog_set_leds(LED_BUSY);