diff options
| author | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2024-09-03 07:42:58 +0200 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2024-09-03 07:42:58 +0200 |
| commit | 35f4a629641b812e04fadef087da5d6af59e32d7 (patch) | |
| tree | 9cd5010ed6c0bf18cb631e60149a16ecccd9e0f3 /io_uring/kbuf.c | |
| parent | fc88bb11617978fb3fcfcc697fd5c9d2dae9c4a3 (diff) | |
| parent | 431c1646e1f86b949fa3685efc50b660a364c2b6 (diff) | |
Merge 6.11-rc6 into usb-next
We need the USB fixes in here as well.
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'io_uring/kbuf.c')
| -rw-r--r-- | io_uring/kbuf.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/io_uring/kbuf.c b/io_uring/kbuf.c index c95dc1736dd9..bdfa30b38321 100644 --- a/io_uring/kbuf.c +++ b/io_uring/kbuf.c @@ -129,7 +129,7 @@ static int io_provided_buffers_select(struct io_kiocb *req, size_t *len, iov[0].iov_base = buf; iov[0].iov_len = *len; - return 0; + return 1; } static struct io_uring_buf *io_ring_head_to_buf(struct io_uring_buf_ring *br, @@ -218,10 +218,13 @@ static int io_ring_buffers_peek(struct io_kiocb *req, struct buf_sel_arg *arg, buf = io_ring_head_to_buf(br, head, bl->mask); if (arg->max_len) { - int needed; + u32 len = READ_ONCE(buf->len); + size_t needed; - needed = (arg->max_len + buf->len - 1) / buf->len; - needed = min(needed, PEEK_MAX_IMPORT); + if (unlikely(!len)) + return -ENOBUFS; + needed = (arg->max_len + len - 1) / len; + needed = min_not_zero(needed, (size_t) PEEK_MAX_IMPORT); if (nr_avail > needed) nr_avail = needed; } |
