freebsd_network: Unlock the taskqueue before waiting for threads.

Also set tq_threads to NULL to prevent double-frees.
This commit is contained in:
Augustin Cavalier
2022-06-22 00:34:37 -04:00
parent 7e1c1d3020
commit a928b16e36
@@ -111,7 +111,10 @@ taskqueue_terminate(struct thread **pp, struct taskqueue *tq)
if (tq->tq_sem == -1)
return;
TQ_UNLOCK(tq);
delete_sem(tq->tq_sem);
tq->tq_sem = -1;
for (int i = 0; i < tq->tq_threadcount; i++) {
status_t status;
@@ -120,6 +123,9 @@ taskqueue_terminate(struct thread **pp, struct taskqueue *tq)
if (tq->tq_threadcount > 1)
free(tq->tq_threads);
tq->tq_threads = NULL;
TQ_LOCK(tq);
}