summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNico Huber <nico.huber@secunet.com>2016-05-04 13:24:07 +0200
committerNico Huber <nico.h@gmx.de>2017-04-20 14:52:47 +0200
commitf84df9a78d35eb458ab19c6dac8a0d5f00013886 (patch)
tree37a94fdf7820d59df6c15ca9aff8339e26cc7755
parent5e5e8213bbd7a0167e61f1138247e7111b6ef031 (diff)
downloadflashrom-git-f84df9a78d35eb458ab19c6dac8a0d5f00013886.tar.gz
dediprog: Fix bug where too many transfers would be queued
We didn't check the total number of queued transfers in the inner most loop. Up to DEDIPROG_ASYNC_TRANSFERS - 1 invalid transfers could be queued therefore. So add another check on the total number. Change-Id: I91a8de47db7107455f5fc63ab2f13a0bd50c5b63 Signed-off-by: Nico Huber <nico.huber@secunet.com> Acked-by: David Hendricks <david.hendricks@gmail.com> Reviewed-on: https://review.coreboot.org/19351 Tested-by: build bot (Jenkins) Reviewed-by: Nico Huber <nico.h@gmx.de>
-rw-r--r--dediprog.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/dediprog.c b/dediprog.c
index b7276e53..6f827724 100644
--- a/dediprog.c
+++ b/dediprog.c
@@ -462,7 +462,9 @@ static int dediprog_spi_bulk_read(struct flashctx *flash, uint8_t *buf, unsigned
/* Now transfer requested chunks using libusb's asynchronous interface. */
while (!status.error && (status.queued_idx < count)) {
- while ((status.queued_idx - status.finished_idx) < DEDIPROG_ASYNC_TRANSFERS) {
+ while ((status.queued_idx < count) &&
+ (status.queued_idx - status.finished_idx) < DEDIPROG_ASYNC_TRANSFERS)
+ {
transfer = transfers[status.queued_idx % DEDIPROG_ASYNC_TRANSFERS];
libusb_fill_bulk_transfer(transfer, dediprog_handle, 0x80 | dediprog_in_endpoint,
(unsigned char *)buf + status.queued_idx * chunksize, chunksize,