Skip to content

Commit e6db6f9

Browse files
committed
io_uring/io-wq: only free worker if it was allocated for creation
We have two types of task_work based creation, one is using an existing worker to setup a new one (eg when going to sleep and we have no free workers), and the other is allocating a new worker. Only the latter should be freed when we cancel task_work creation for a new worker. Fixes: af82425 ("io_uring/io-wq: free worker if task_work creation is canceled") Reported-by: [email protected] Signed-off-by: Jens Axboe <[email protected]>
1 parent 12521a5 commit e6db6f9

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

io_uring/io-wq.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1230,7 +1230,12 @@ static void io_wq_cancel_tw_create(struct io_wq *wq)
12301230

12311231
worker = container_of(cb, struct io_worker, create_work);
12321232
io_worker_cancel_cb(worker);
1233-
kfree(worker);
1233+
/*
1234+
* Only the worker continuation helper has worker allocated and
1235+
* hence needs freeing.
1236+
*/
1237+
if (cb->func == create_worker_cont)
1238+
kfree(worker);
12341239
}
12351240
}
12361241

0 commit comments

Comments
 (0)