Skip to content

Commit 6f007b1

Browse files
committed
io_uring: don't guard IORING_OFF_PBUF_RING with SETUP_NO_MMAP
This flag only applies to the SQ and CQ rings, it's perfectly valid to use a mmap approach for the provided ring buffers. Move the check into where it belongs. Cc: [email protected] Fixes: 03d89a2 ("io_uring: support for user allocated memory for rings/sqes") Signed-off-by: Jens Axboe <[email protected]>
1 parent 820d070 commit 6f007b1

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

io_uring/io_uring.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3478,16 +3478,18 @@ static void *io_uring_validate_mmap_request(struct file *file,
34783478
struct page *page;
34793479
void *ptr;
34803480

3481-
/* Don't allow mmap if the ring was setup without it */
3482-
if (ctx->flags & IORING_SETUP_NO_MMAP)
3483-
return ERR_PTR(-EINVAL);
3484-
34853481
switch (offset & IORING_OFF_MMAP_MASK) {
34863482
case IORING_OFF_SQ_RING:
34873483
case IORING_OFF_CQ_RING:
3484+
/* Don't allow mmap if the ring was setup without it */
3485+
if (ctx->flags & IORING_SETUP_NO_MMAP)
3486+
return ERR_PTR(-EINVAL);
34883487
ptr = ctx->rings;
34893488
break;
34903489
case IORING_OFF_SQES:
3490+
/* Don't allow mmap if the ring was setup without it */
3491+
if (ctx->flags & IORING_SETUP_NO_MMAP)
3492+
return ERR_PTR(-EINVAL);
34913493
ptr = ctx->sq_sqes;
34923494
break;
34933495
case IORING_OFF_PBUF_RING: {

0 commit comments

Comments
 (0)