diff --git a/io_uring/io-wq.c b/io_uring/io-wq.c index edcb5af514b5..f57743d911b4 100644 --- a/io_uring/io-wq.c +++ b/io_uring/io-wq.c @@ -195,9 +195,12 @@ static void io_worker_cancel_cb(struct io_worker *worker) struct io_wq *wq = wqe->wq; atomic_dec(&acct->nr_running); - raw_spin_lock(&worker->wqe->lock); - acct->nr_workers--; - raw_spin_unlock(&worker->wqe->lock); + /* create_worker_cb() has not reserved a worker slot yet. */ + if (worker->create_work.func != create_worker_cb) { + raw_spin_lock(&worker->wqe->lock); + acct->nr_workers--; + raw_spin_unlock(&worker->wqe->lock); + } io_worker_ref_put(wq); clear_bit_unlock(0, &worker->create_state); io_worker_release(worker);