summary refs log tree commit diff
path: root/io_uring
diff options
context:
space:
mode:
authorWojciech Lukowicz <wlukowicz01@gmail.com>2023-04-01 20:50:38 +0100
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2023-04-13 16:55:31 +0200
commitbd4081fa1cd9563d112155a5aa58fbba7bb4f647 (patch)
treed4c1bd15e18bf012801c4d44a867b3a69efce4b6 /io_uring
parent9f03d09b090cd07906917ac757e0efb28f37d2e4 (diff)
downloadlinux-bd4081fa1cd9563d112155a5aa58fbba7bb4f647.tar.gz
io_uring: fix return value when removing provided buffers
[ Upstream commit c0921e51dab767ef5adf6175c4a0ba3c6e1074a3 ]

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: dbc7d452e7cf ("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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'io_uring')
-rw-r--r--io_uring/kbuf.c2
1 files changed, 0 insertions, 2 deletions
diff --git a/io_uring/kbuf.c b/io_uring/kbuf.c
index 746b137b96e9..9a9db1fcdc14 100644
--- a/io_uring/kbuf.c
+++ b/io_uring/kbuf.c
@@ -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;
 
@@ -238,7 +237,6 @@ static int __io_remove_buffers(struct io_ring_ctx *ctx,
 			return i;
 		cond_resched();
 	}
-	i++;
 
 	return i;
 }