Skip to content

Commit

Permalink
io_uring/kbuf: check for buffer list readiness after NULL check
Browse files Browse the repository at this point in the history
Move the buffer list 'is_ready' check below the validity check for
the buffer list for a given group.

Fixes: 5cf4f52 ("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>
  • Loading branch information
Jens Axboe committed Dec 5, 2023
1 parent e53f7b5 commit 9865346
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions io_uring/kbuf.c
Original file line number Diff line number Diff line change
Expand Up @@ -756,15 +756,15 @@ 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
* the xarray lookups, it's either visible and ready, or not at all.
*/
if (!smp_load_acquire(&bl->is_ready))
return NULL;
if (!bl || !bl->is_mmap)
return NULL;

return bl->buf_ring;
}
Expand Down

0 comments on commit 9865346

Please sign in to comment.