Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

Pavel Begunkov and committed by
Jens Axboe
06897ddf e9a9ddb1

+14 -13
+14 -13
io_uring/zcrx.c
··· 141 141 struct net_iov *niov = &area->nia.niovs[niov_idx]; 142 142 143 143 if (net_mp_niov_set_dma_addr(niov, dma)) 144 - return 0; 144 + return -EFAULT; 145 145 sg_len -= PAGE_SIZE; 146 146 dma += PAGE_SIZE; 147 147 niov_idx++; 148 148 } 149 149 } 150 - return niov_idx; 150 + return 0; 151 151 } 152 152 153 153 static int io_import_umem(struct io_zcrx_ifq *ifq, ··· 256 256 break; 257 257 } 258 258 } 259 - return i; 259 + 260 + if (i != area->nia.num_niovs) { 261 + __io_zcrx_unmap_area(ifq, area, i); 262 + return -EINVAL; 263 + } 264 + return 0; 260 265 } 261 266 262 267 static int io_zcrx_map_area(struct io_zcrx_ifq *ifq, struct io_zcrx_area *area) 263 268 { 264 - unsigned nr; 269 + int ret; 265 270 266 271 guard(mutex)(&ifq->dma_lock); 267 272 if (area->is_mapped) 268 273 return 0; 269 274 270 275 if (area->mem.is_dmabuf) 271 - nr = io_zcrx_map_area_dmabuf(ifq, area); 276 + ret = io_zcrx_map_area_dmabuf(ifq, area); 272 277 else 273 - nr = io_zcrx_map_area_umem(ifq, area); 278 + ret = io_zcrx_map_area_umem(ifq, area); 274 279 275 - if (nr != area->nia.num_niovs) { 276 - __io_zcrx_unmap_area(ifq, area, nr); 277 - return -EINVAL; 278 - } 279 - 280 - area->is_mapped = true; 281 - return 0; 280 + if (ret == 0) 281 + area->is_mapped = true; 282 + return ret; 282 283 } 283 284 284 285 static void io_zcrx_sync_for_device(const struct page_pool *pool,