Skip to content

Commit cef59d1

Browse files
isilenceaxboe
authored andcommitted
io_uring: clean rings on NO_MMAP alloc fail
We make a few cancellation judgements based on ctx->rings, so let's zero it afer deallocation for IORING_SETUP_NO_MMAP just like it's done with the mmap case. Likely, it's not a real problem, but zeroing is safer and better tested. Cc: stable@vger.kernel.org Fixes: 03d89a2 ("io_uring: support for user allocated memory for rings/sqes") Signed-off-by: Pavel Begunkov <asml.silence@gmail.com> Link: https://lore.kernel.org/r/9ff6cdf91429b8a51699c210e1f6af6ea3f8bdcf.1710255382.git.asml.silence@gmail.com Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 0a3737d commit cef59d1

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

io_uring/io_uring.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2788,14 +2788,15 @@ static void io_rings_free(struct io_ring_ctx *ctx)
27882788
if (!(ctx->flags & IORING_SETUP_NO_MMAP)) {
27892789
io_mem_free(ctx->rings);
27902790
io_mem_free(ctx->sq_sqes);
2791-
ctx->rings = NULL;
2792-
ctx->sq_sqes = NULL;
27932791
} else {
27942792
io_pages_free(&ctx->ring_pages, ctx->n_ring_pages);
27952793
ctx->n_ring_pages = 0;
27962794
io_pages_free(&ctx->sqe_pages, ctx->n_sqe_pages);
27972795
ctx->n_sqe_pages = 0;
27982796
}
2797+
2798+
ctx->rings = NULL;
2799+
ctx->sq_sqes = NULL;
27992800
}
28002801

28012802
void *io_mem_alloc(size_t size)

0 commit comments

Comments
 (0)