Skip to content

Commit d9f595b

Browse files
isilenceaxboe
authored andcommitted
io_uring/zcrx: fix leaking pages on sg init fail
If sg_alloc_table_from_pages() fails, io_import_umem() returns without cleaning up pinned pages first. Fix it. Fixes: b84621d ("io_uring/zcrx: allocate sgtable for umem areas") Signed-off-by: Pavel Begunkov <[email protected]> Link: https://lore.kernel.org/r/9fd94d1bc8c316611eccfec7579799182ff3fb0a.1753091564.git.asml.silence@gmail.com Signed-off-by: Jens Axboe <[email protected]>
1 parent 6bbd341 commit d9f595b

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

io_uring/zcrx.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,8 +194,10 @@ static int io_import_umem(struct io_zcrx_ifq *ifq,
194194
ret = sg_alloc_table_from_pages(&mem->page_sg_table, pages, nr_pages,
195195
0, nr_pages << PAGE_SHIFT,
196196
GFP_KERNEL_ACCOUNT);
197-
if (ret)
197+
if (ret) {
198+
unpin_user_pages(pages, nr_pages);
198199
return ret;
200+
}
199201

200202
mem->account_pages = io_count_account_pages(pages, nr_pages);
201203
ret = io_account_mem(ifq->ctx, mem->account_pages);

0 commit comments

Comments
 (0)