Skip to content

Commit f1596ba

Browse files
Jaeyeong Leeaxboe
authored andcommitted
io_uring/kbuf: free the replaced iovec after a successful grow
The provided-buffer validation fix deferred freeing a cached iovec until validation completed. However, the deferred free uses arg->iovs. After a grow, that points to the newly allocated array. Without a grow, it points to the cached array that remains in use. This leaves the caller with a dangling iovec in both cases and can result in repeated frees. Only free org_iovs when arg->iovs actually replaced it. Fixes: cd053d7 ("io_uring: fix dangling iovec after provided-buffer bundle grow failure") Assisted-by: Codex:gpt-5.3-codex-spark Signed-off-by: Jaeyeong Lee <iostreampy@proton.me> Link: https://patch.msgid.link/20260712142612.188695595-iostreampy@proton.me Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent f3176c8 commit f1596ba

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

io_uring/kbuf.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -328,8 +328,8 @@ static int io_ring_buffers_peek(struct io_kiocb *req, struct buf_sel_arg *arg,
328328
buf = io_ring_head_to_buf(br, ++head, bl->mask);
329329
} while (--nr_iovs);
330330

331-
if (arg->mode & KBUF_MODE_FREE)
332-
kfree(arg->iovs);
331+
if (arg->iovs != org_iovs && (arg->mode & KBUF_MODE_FREE))
332+
kfree(org_iovs);
333333

334334
if (head == tail)
335335
req->flags |= REQ_F_BL_EMPTY;

0 commit comments

Comments
 (0)