]> git.baikalelectronics.ru Git - kernel.git/commit
io_uring: fix deferred req iovec leak
authorPavel Begunkov <asml.silence@gmail.com>
Thu, 6 Feb 2020 16:51:16 +0000 (19:51 +0300)
committerJens Axboe <axboe@kernel.dk>
Thu, 6 Feb 2020 20:58:57 +0000 (13:58 -0700)
commit0d09f5982e7d9ac34ad08b6fe9d1ea25edfa29ea
tree35f81194060211299102a3e9ce37349a338ae6c0
parent9d09cdbab3c65ee79bc301ea4308bafab5f556d3
io_uring: fix deferred req iovec leak

After defer, a request will be prepared, that includes allocating iovec
if needed, and then submitted through io_wq_submit_work() but not custom
handler (e.g. io_rw_async()/io_sendrecv_async()). However, it'll leak
iovec, as it's in io-wq and the code goes as follows:

io_read() {
if (!io_wq_current_is_worker())
kfree(iovec);
}

Put all deallocation logic in io_{read,write,send,recv}(), which will
leave the memory, if going async with -EAGAIN.

It also fixes a leak after failed io_alloc_async_ctx() in
io_{recv,send}_msg().

Cc: stable@vger.kernel.org # 5.5
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
fs/io_uring.c