From: Jens Axboe Date: Tue, 8 Dec 2015 19:37:30 +0000 (-0700) Subject: workqueue: make workqueue_exit() safe for multiple exit calls X-Git-Tag: fio-2.2.13~21 X-Git-Url: https://git.kernel.dk/?p=fio.git;a=commitdiff_plain;h=f8e266c9ef5a4754f3482b71d2e0f239cf2a1d28 workqueue: make workqueue_exit() safe for multiple exit calls This might happen if we fail init. Signed-off-by: Jens Axboe --- diff --git a/workqueue.c b/workqueue.c index 06fc2631..5fd95b90 100644 --- a/workqueue.c +++ b/workqueue.c @@ -234,6 +234,9 @@ void workqueue_exit(struct workqueue *wq) struct submit_worker *sw; int i; + if (!wq->workers) + return; + for (i = 0; i < wq->max_workers; i++) { sw = &wq->workers[i]; @@ -258,6 +261,7 @@ void workqueue_exit(struct workqueue *wq) } while (shutdown && shutdown != wq->max_workers); free(wq->workers); + wq->workers = NULL; pthread_mutex_destroy(&wq->flush_lock); pthread_cond_destroy(&wq->flush_cond); pthread_mutex_destroy(&wq->stat_lock);