diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2023-04-08 11:34:17 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2023-04-08 11:34:17 -0700 |
commit | d3f05a4c428565163f26b5d34f60f02ee4ea4009 (patch) | |
tree | d575facda7a2a6c97a7bcd874168c22b094782ff /io_uring/kbuf.c | |
parent | 973ad544f04a5eff3435fd36e02392c5afeafc0f (diff) | |
parent | b4a72c0589fdea6259720375426179888969d6a2 (diff) |
Merge tag 'io_uring-6.3-2023-04-06' of git://git.kernel.dk/linux
Pull io_uring fixes from Jens Axboe:
"Just two minor fixes for provided buffers - one where we could
potentially leak a buffer, and one where the returned values was
off-by-one in some cases"
* tag 'io_uring-6.3-2023-04-06' of git://git.kernel.dk/linux:
io_uring: fix memory leak when removing provided buffers
io_uring: fix return value when removing provided buffers
Diffstat (limited to 'io_uring/kbuf.c')
-rw-r--r-- | io_uring/kbuf.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/io_uring/kbuf.c b/io_uring/kbuf.c index 3002dc827195..a90c820ce99e 100644 --- a/io_uring/kbuf.c +++ b/io_uring/kbuf.c @@ -228,17 +228,18 @@ static int __io_remove_buffers(struct io_ring_ctx *ctx, return i; } - /* the head kbuf is the list itself */ + /* protects io_buffers_cache */ + lockdep_assert_held(&ctx->uring_lock); + while (!list_empty(&bl->buf_list)) { struct io_buffer *nxt; nxt = list_first_entry(&bl->buf_list, struct io_buffer, list); - list_del(&nxt->list); + list_move(&nxt->list, &ctx->io_buffers_cache); if (++i == nbufs) return i; cond_resched(); } - i++; return i; } |