Skip to content

Commit 9865346

Browse files
committed
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: 5cf4f52 ("io_uring: free io_buffer_list entries via RCU") Reported-by: Dan Carpenter <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent e53f7b5 commit 9865346

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

io_uring/kbuf.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -756,15 +756,15 @@ void *io_pbuf_get_address(struct io_ring_ctx *ctx, unsigned long bgid)
756756

757757
bl = __io_buffer_get_list(ctx, smp_load_acquire(&ctx->io_bl), bgid);
758758

759+
if (!bl || !bl->is_mmap)
760+
return NULL;
759761
/*
760762
* Ensure the list is fully setup. Only strictly needed for RCU lookup
761763
* via mmap, and in that case only for the array indexed groups. For
762764
* the xarray lookups, it's either visible and ready, or not at all.
763765
*/
764766
if (!smp_load_acquire(&bl->is_ready))
765767
return NULL;
766-
if (!bl || !bl->is_mmap)
767-
return NULL;
768768

769769
return bl->buf_ring;
770770
}

0 commit comments

Comments
 (0)