diff --git a/io_uring/io-wq.c b/io_uring/io-wq.c index e93cfa82b850..28533174d0da 100644 --- a/io_uring/io-wq.c +++ b/io_uring/io-wq.c @@ -1420,6 +1420,12 @@ void io_wq_exit_start(struct io_wq *wq) set_bit(IO_WQ_BIT_EXIT, &wq->state); /* Pairs with task_work_add() in io_queue_worker_create(). */ smp_mb__after_atomic(); + /* + * No more workers from here on. The caller is going to run its task + * work, and on exec a thread that is created now would still be + * around, exiting, by the time that the caller must be on its own. + */ + io_wq_cancel_tw_create(wq); } static void io_wq_cancel_tw_create(struct io_wq *wq)