diff --git a/lib/libzpool/taskq.c b/lib/libzpool/taskq.c index b1e71e998..a2e457ef9 100644 --- a/lib/libzpool/taskq.c +++ b/lib/libzpool/taskq.c @@ -319,7 +319,9 @@ taskq_destroy(taskq_t *tq) tq->tq_minalloc = 0; while (tq->tq_nalloc != 0) { ASSERT(tq->tq_freelist != NULL); - task_free(tq, task_alloc(tq, KM_SLEEP)); + taskq_ent_t *tqent_nexttq = tq->tq_freelist->tqent_next; + task_free(tq, tq->tq_freelist); + tq->tq_freelist = tqent_nexttq; } mutex_exit(&tq->tq_lock);