summaryrefslogtreecommitdiff
path: root/io_uring
diff options
context:
space:
mode:
authorPavel Begunkov <asml.silence@gmail.com>2025-07-02 15:29:05 +0100
committerJens Axboe <axboe@kernel.dk>2025-07-08 11:59:56 -0600
commit06897ddfc523cea415bd139148c5276b8b61b016 (patch)
tree956b472c102bf49d6dd985721043122d9dfa4ff1 /io_uring
parente9a9ddb15b092eb4dc0d34a3e043e73f2510a6b0 (diff)
downloadlinux-06897ddfc523cea415bd139148c5276b8b61b016.tar.gz
linux-06897ddfc523cea415bd139148c5276b8b61b016.tar.bz2
linux-06897ddfc523cea415bd139148c5276b8b61b016.zip
io_uring/zcrx: return error from io_zcrx_map_area_*
io_zcrx_map_area_*() helpers return the number of processed niovs, which we use to unroll some of the mappings for user memory areas. It's unhandy, and dmabuf doesn't care about it. Return an error code instead and move failure partial unmapping into io_zcrx_map_area_umem(). Signed-off-by: Pavel Begunkov <asml.silence@gmail.com> Reviewed-by: David Wei <dw@davidwei.uk> Link: https://lore.kernel.org/r/42668e82be3a84b07ee8fc76d1d6d5ac0f137fe5.1751466461.git.asml.silence@gmail.com Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'io_uring')
-rw-r--r--io_uring/zcrx.c27
1 files changed, 14 insertions, 13 deletions
diff --git a/io_uring/zcrx.c b/io_uring/zcrx.c
index e94a4647d409..6fb7c9bedfcb 100644
--- a/io_uring/zcrx.c
+++ b/io_uring/zcrx.c
@@ -141,13 +141,13 @@ static int io_zcrx_map_area_dmabuf(struct io_zcrx_ifq *ifq, struct io_zcrx_area
struct net_iov *niov = &area->nia.niovs[niov_idx];
if (net_mp_niov_set_dma_addr(niov, dma))
- return 0;
+ return -EFAULT;
sg_len -= PAGE_SIZE;
dma += PAGE_SIZE;
niov_idx++;
}
}
- return niov_idx;
+ return 0;
}
static int io_import_umem(struct io_zcrx_ifq *ifq,
@@ -256,29 +256,30 @@ static int io_zcrx_map_area_umem(struct io_zcrx_ifq *ifq, struct io_zcrx_area *a
break;
}
}
- return i;
+
+ if (i != area->nia.num_niovs) {
+ __io_zcrx_unmap_area(ifq, area, i);
+ return -EINVAL;
+ }
+ return 0;
}
static int io_zcrx_map_area(struct io_zcrx_ifq *ifq, struct io_zcrx_area *area)
{
- unsigned nr;
+ int ret;
guard(mutex)(&ifq->dma_lock);
if (area->is_mapped)
return 0;
if (area->mem.is_dmabuf)
- nr = io_zcrx_map_area_dmabuf(ifq, area);
+ ret = io_zcrx_map_area_dmabuf(ifq, area);
else
- nr = io_zcrx_map_area_umem(ifq, area);
+ ret = io_zcrx_map_area_umem(ifq, area);
- if (nr != area->nia.num_niovs) {
- __io_zcrx_unmap_area(ifq, area, nr);
- return -EINVAL;
- }
-
- area->is_mapped = true;
- return 0;
+ if (ret == 0)
+ area->is_mapped = true;
+ return ret;
}
static void io_zcrx_sync_for_device(const struct page_pool *pool,