Commit 9865346b authored by Jens Axboe's avatar Jens Axboe

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: 5cf4f52e ("io_uring: free io_buffer_list entries via RCU")
Reported-by: default avatarDan Carpenter <dan.carpenter@linaro.org>
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent e53f7b54
...@@ -756,6 +756,8 @@ void *io_pbuf_get_address(struct io_ring_ctx *ctx, unsigned long bgid) ...@@ -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); 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 * 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 * 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) ...@@ -763,8 +765,6 @@ void *io_pbuf_get_address(struct io_ring_ctx *ctx, unsigned long bgid)
*/ */
if (!smp_load_acquire(&bl->is_ready)) if (!smp_load_acquire(&bl->is_ready))
return NULL; return NULL;
if (!bl || !bl->is_mmap)
return NULL;
return bl->buf_ring; return bl->buf_ring;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment