Skip to content

Commit

Permalink
io_uring: fix return value when removing provided buffers
Browse files Browse the repository at this point in the history
When a request to remove buffers is submitted, and the given number to be
removed is larger than available in the specified buffer group, the
resulting CQE result will be the number of removed buffers + 1, which is
1 more than it should be.

Previously, the head was part of the list and it got removed after the
loop, so the increment was needed. Now, the head is not an element of
the list, so the increment shouldn't be there anymore.

Fixes: dbc7d45 ("io_uring: manage provided buffers strictly ordered")
Signed-off-by: Wojciech Lukowicz <wlukowicz01@gmail.com>
Link: https://lore.kernel.org/r/20230401195039.404909-2-wlukowicz01@gmail.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
  • Loading branch information
Wojciech Lukowicz authored and Jens Axboe committed Apr 1, 2023
1 parent fd30d1c commit c0921e5
Showing 1 changed file with 0 additions and 2 deletions.
2 changes: 0 additions & 2 deletions io_uring/kbuf.c
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,6 @@ static int __io_remove_buffers(struct io_ring_ctx *ctx,
return i;
}

/* the head kbuf is the list itself */
while (!list_empty(&bl->buf_list)) {
struct io_buffer *nxt;

Expand All @@ -238,7 +237,6 @@ static int __io_remove_buffers(struct io_ring_ctx *ctx,
return i;
cond_resched();
}
i++;

return i;
}
Expand Down

0 comments on commit c0921e5

Please sign in to comment.