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: fully clean area on error in io_import_umem()

When accounting fails, io_import_umem() sets the page array, etc. and
returns an error expecting that the error handling code will take care
of the rest. To make the next patch simpler, only return a fully
initialised areas from the function.

Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Link: https://patch.msgid.link/3a602b7fb347dbd4da6797ac49b52ea5dedb856d.1774261953.git.asml.silence@gmail.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>

authored by

Pavel Begunkov and committed by
Jens Axboe
41041562 e5361d25

+10 -6
+10 -6
io_uring/zcrx.c
··· 207 207 ret = sg_alloc_table_from_pages(&mem->page_sg_table, pages, nr_pages, 208 208 0, (unsigned long)nr_pages << PAGE_SHIFT, 209 209 GFP_KERNEL_ACCOUNT); 210 - if (ret) { 211 - unpin_user_pages(pages, nr_pages); 212 - kvfree(pages); 213 - return ret; 214 - } 210 + if (ret) 211 + goto out_err; 215 212 216 213 mem->account_pages = io_count_account_pages(pages, nr_pages); 217 214 ret = io_account_mem(ifq->user, ifq->mm_account, mem->account_pages); 218 - if (ret < 0) 215 + if (ret < 0) { 219 216 mem->account_pages = 0; 217 + goto out_err; 218 + } 220 219 221 220 mem->sgt = &mem->page_sg_table; 222 221 mem->pages = pages; 223 222 mem->nr_folios = nr_pages; 224 223 mem->size = area_reg->len; 224 + return ret; 225 + out_err: 226 + sg_free_table(&mem->page_sg_table); 227 + unpin_user_pages(pages, nr_pages); 228 + kvfree(pages); 225 229 return ret; 226 230 } 227 231