Skip to content

Commit

Permalink
io_uring/io-wq: only free worker if it was allocated for creation
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
axboe committed Jan 8, 2023
1 parent 12521a5 commit e6db6f9
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion io_uring/io-wq.c
Original file line number Diff line number Diff line change
Expand Up @@ -1230,7 +1230,12 @@ static void io_wq_cancel_tw_create(struct io_wq *wq)

worker = container_of(cb, struct io_worker, create_work);
io_worker_cancel_cb(worker);
kfree(worker);
/*
* Only the worker continuation helper has worker allocated and
* hence needs freeing.
*/
if (cb->func == create_worker_cont)
kfree(worker);
}
}

Expand Down

0 comments on commit e6db6f9

Please sign in to comment.