[PATCH io_uring-7.1 v2 3/5] io_uring/zcrx: don't clear not allocated niovs

Pavel Begunkov
2026-03-25T13:09:22Z

Now that area->is_mapped is set earlier before niovs array is allocated,
io_zcrx_free_area -> io_zcrx_unmap_area in an error path can try to
clear dma addresses for unallocated niovs, fix it.

Fixes: 8c0cab0b7bf76 ("always dma map in advance")
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
---
io_uring/zcrx.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/io_uring/zcrx.c b/io_uring/zcrx.c
index dede892bdda9..d9174cb31a44 100644
--- a/io_uring/zcrx.c
+++ b/io_uring/zcrx.c
@@ -289,8 +289,10 @@ static void io_zcrx_unmap_area(struct io_zcrx_ifq *ifq,
return;
area->is_mapped = false;

- for (i = 0; i < area->nia.num_niovs; i++)
- net_mp_niov_set_dma_addr(&area->nia.niovs[i], 0);
+ if (area->nia.niovs) {
+ for (i = 0; i < area->nia.num_niovs; i++)
+ net_mp_niov_set_dma_addr(&area->nia.niovs[i], 0);
+ }

if (area->mem.is_dmabuf) {
io_release_dmabuf(&area->mem);
--
2.53.0