public inbox for [email protected]
 help / color / mirror / Atom feed
* [PATCH 1/1] io_uring: clean rings on NO_MMAP alloc fail
@ 2024-03-12 14:56 Pavel Begunkov
  2024-03-13 20:27 ` Jens Axboe
  0 siblings, 1 reply; 2+ messages in thread
From: Pavel Begunkov @ 2024-03-12 14:56 UTC (permalink / raw)
  To: io-uring; +Cc: Jens Axboe, asml.silence

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: [email protected]
Fixes: 03d89a2de25bbc ("io_uring: support for user allocated memory for rings/sqes")
Signed-off-by: Pavel Begunkov <[email protected]>
---
 io_uring/io_uring.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/io_uring/io_uring.c b/io_uring/io_uring.c
index 49a124daa359..e7d7a456b489 100644
--- a/io_uring/io_uring.c
+++ b/io_uring/io_uring.c
@@ -2788,14 +2788,15 @@ static void io_rings_free(struct io_ring_ctx *ctx)
 	if (!(ctx->flags & IORING_SETUP_NO_MMAP)) {
 		io_mem_free(ctx->rings);
 		io_mem_free(ctx->sq_sqes);
-		ctx->rings = NULL;
-		ctx->sq_sqes = NULL;
 	} else {
 		io_pages_free(&ctx->ring_pages, ctx->n_ring_pages);
 		ctx->n_ring_pages = 0;
 		io_pages_free(&ctx->sqe_pages, ctx->n_sqe_pages);
 		ctx->n_sqe_pages = 0;
 	}
+
+	ctx->rings = NULL;
+	ctx->sq_sqes = NULL;
 }
 
 void *io_mem_alloc(size_t size)
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH 1/1] io_uring: clean rings on NO_MMAP alloc fail
  2024-03-12 14:56 [PATCH 1/1] io_uring: clean rings on NO_MMAP alloc fail Pavel Begunkov
@ 2024-03-13 20:27 ` Jens Axboe
  0 siblings, 0 replies; 2+ messages in thread
From: Jens Axboe @ 2024-03-13 20:27 UTC (permalink / raw)
  To: io-uring, Pavel Begunkov


On Tue, 12 Mar 2024 14:56:27 +0000, Pavel Begunkov wrote:
> 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.
> 
> 

Applied, thanks!

[1/1] io_uring: clean rings on NO_MMAP alloc fail
      commit: cef59d1ea7170ec753182302645a0191c8aa3382

Best regards,
-- 
Jens Axboe




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-03-13 20:27 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-12 14:56 [PATCH 1/1] io_uring: clean rings on NO_MMAP alloc fail Pavel Begunkov
2024-03-13 20:27 ` Jens Axboe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox