aboutsummaryrefslogtreecommitdiffstats
path: root/io_uring
diff options
context:
space:
mode:
authorJens Axboe <axboe@kernel.dk>2023-12-05 07:02:13 -0700
committerJens Axboe <axboe@kernel.dk>2023-12-05 07:02:13 -0700
commit9865346b7e8374b57f1c3ccacdc77846c6352ff4 (patch)
tree348389fae84b4a08f1c98c46ec8d7e7b9f6077d0 /io_uring
parente53f7b54b1fdecae897f25002ff0cff04faab228 (diff)
downloadlinux-9865346b7e8374b57f1c3ccacdc77846c6352ff4.tar.gz
io_uring/kbuf: check for buffer list readiness after NULL check
Move the buffer list 'is_ready' check below the validity check for the buffer list for a given group. Fixes: 5cf4f52e6d8a ("io_uring: free io_buffer_list entries via RCU") Reported-by: Dan Carpenter <dan.carpenter@linaro.org> Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'io_uring')
-rw-r--r--io_uring/kbuf.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/io_uring/kbuf.c b/io_uring/kbuf.c
index bd25bc2deeaf83..72b6af1d2ed3b0 100644
--- a/io_uring/kbuf.c
+++ b/io_uring/kbuf.c
@@ -756,6 +756,8 @@ void *io_pbuf_get_address(struct io_ring_ctx *ctx, unsigned long bgid)
bl = __io_buffer_get_list(ctx, smp_load_acquire(&ctx->io_bl), bgid);
+ if (!bl || !bl->is_mmap)
+ return NULL;
/*
* Ensure the list is fully setup. Only strictly needed for RCU lookup
* via mmap, and in that case only for the array indexed groups. For
@@ -763,8 +765,6 @@ void *io_pbuf_get_address(struct io_ring_ctx *ctx, unsigned long bgid)
*/
if (!smp_load_acquire(&bl->is_ready))
return NULL;
- if (!bl || !bl->is_mmap)
- return NULL;
return bl->buf_ring;
}