Skip to content

Commit 1251d20

Browse files
committed
io_uring/sqpoll: early exit thread if task_context wasn't allocated
Ideally we'd want to simply kill the task rather than wake it, but for now let's just add a startup check that causes the thread to exit. This can only happen if io_uring_alloc_task_context() fails, which generally requires fault injection. Reported-by: Ubisectech Sirius <bugreport@ubisectech.com> Fixes: af5d68f ("io_uring/sqpoll: manage task_work privately") Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent e21e1c4 commit 1251d20

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

io_uring/sqpoll.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,10 @@ static int io_sq_thread(void *data)
274274
char buf[TASK_COMM_LEN];
275275
DEFINE_WAIT(wait);
276276

277+
/* offload context creation failed, just exit */
278+
if (!current->io_uring)
279+
goto err_out;
280+
277281
snprintf(buf, sizeof(buf), "iou-sqp-%d", sqd->task_pid);
278282
set_task_comm(current, buf);
279283

@@ -371,7 +375,7 @@ static int io_sq_thread(void *data)
371375
atomic_or(IORING_SQ_NEED_WAKEUP, &ctx->rings->sq_flags);
372376
io_run_task_work();
373377
mutex_unlock(&sqd->lock);
374-
378+
err_out:
375379
complete(&sqd->exited);
376380
do_exit(0);
377381
}

0 commit comments

Comments
 (0)