Commit 8a378fb0 authored by Jens Axboe's avatar Jens Axboe
Browse files

io_uring: ensure io-wq context is always destroyed for tasks



If the task ends up doing no IO, the context list is empty and we don't
call into __io_uring_files_cancel() when the task exits. This can cause
a leak of the io-wq structures.

Ensure we always call __io_uring_files_cancel(), even if the task
context list is empty.

Fixes: 5aa75ed5 ("io_uring: tie async worker side to the task context")
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 0100e6bb
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -8800,11 +8800,12 @@ void __io_uring_files_cancel(struct files_struct *files)

	if (files) {
		io_uring_remove_task_files(tctx);
	} else if (tctx->io_wq && current->flags & PF_EXITING) {
		if (tctx->io_wq) {
			io_wq_destroy(tctx->io_wq);
			tctx->io_wq = NULL;
		}
	}
}

static s64 tctx_inflight(struct io_uring_task *tctx)
{
+1 −1
Original line number Diff line number Diff line
@@ -43,7 +43,7 @@ static inline void io_uring_task_cancel(void)
}
static inline void io_uring_files_cancel(struct files_struct *files)
{
	if (current->io_uring && !xa_empty(&current->io_uring->xa))
	if (current->io_uring)
		__io_uring_files_cancel(files);
}
static inline void io_uring_free(struct task_struct *tsk)