diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c index 58d0edbd56..eea3e81de6 100644 --- a/hw/scsi/esp.c +++ b/hw/scsi/esp.c @@ -754,7 +754,8 @@ static void esp_do_nodma(ESPState *s) } if (to_device) { - len = MIN(fifo8_num_used(&s->fifo), ESP_FIFO_SZ); + len = MIN(s->async_len, ESP_FIFO_SZ); + len = MIN(len, fifo8_num_used(&s->fifo)); esp_fifo_pop_buf(&s->fifo, s->async_buf, len); s->async_buf += len; s->async_len -= len;