Fix memory leak found by GCC static analyzer

GCC 12.1.1_p20220625's -fanalyzer found and reported this.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Damian Szuberski <szuberskidamian@gmail.com>
Signed-off-by: Richard Yao <richard.yao@alumni.stonybrook.edu>
Closes #13975
This commit is contained in:
Richard Yao 2022-10-03 16:41:58 -04:00 committed by GitHub
parent 67395be0c2
commit d62bafee9f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 1 deletions

View File

@ -319,7 +319,9 @@ taskq_destroy(taskq_t *tq)
tq->tq_minalloc = 0; tq->tq_minalloc = 0;
while (tq->tq_nalloc != 0) { while (tq->tq_nalloc != 0) {
ASSERT(tq->tq_freelist != NULL); 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); mutex_exit(&tq->tq_lock);