From: Daniel Gomez <[email protected]>

dma_blk_cb() submits dbs->iov to io_func() in one shot, so callers
must keep dbs->iov.niov below IOV_MAX or the host preadv()/pwritev()
rejects the call.

Break the accumulation loop when niov reaches IOV_MAX. The existing
re-entry path resumes mapping and submits a follow-up chunk under
the same AIOCB, so callers no longer carry that constraint.

Suggested-by: Klaus Jensen <[email protected]>
Signed-off-by: Daniel Gomez <[email protected]>
---
 system/dma-helpers.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/system/dma-helpers.c b/system/dma-helpers.c
index d4fd33a3d4c..613fa548669 100644
--- a/system/dma-helpers.c
+++ b/system/dma-helpers.c
@@ -175,6 +175,9 @@ static void dma_blk_cb(void *opaque, int ret)
             dbs->sg_cur_byte = 0;
             ++dbs->sg_cur_index;
         }
+        if (dbs->iov.niov >= IOV_MAX) {
+            break;
+        }
     }
 
     if (dbs->iov.size == 0) {

-- 
2.55.0


Reply via email to