From 3de228499a1242ddcd6717000dbe9d98e3736677 Mon Sep 17 00:00:00 2001 From: Matt Macy Date: Mon, 28 May 2018 23:16:39 +0000 Subject: [PATCH] hwmpc: fix brain-damaged handling of thread descriptor freeing --- sys/dev/hwpmc/hwpmc_mod.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sys/dev/hwpmc/hwpmc_mod.c b/sys/dev/hwpmc/hwpmc_mod.c index 3cdbfe60f9aa..9969408ad4b2 100644 --- a/sys/dev/hwpmc/hwpmc_mod.c +++ b/sys/dev/hwpmc/hwpmc_mod.c @@ -2351,9 +2351,9 @@ pmc_thread_descriptor_pool_free_task(void *arg __unused) /* Determine what changes, if any, we need to make. */ mtx_lock_spin(&pmc_threadfreelist_mtx); delta = pmc_threadfreelist_entries - pmc_threadfreelist_max; - while (delta > 0) { - pt = LIST_FIRST(&pmc_threadfreelist); - MPASS(pt); + while (delta > 0 && + (pt = LIST_FIRST(&pmc_threadfreelist)) != NULL) { + delta--; LIST_REMOVE(pt, pt_next); LIST_INSERT_HEAD(&tmplist, pt, pt_next); } @@ -2361,7 +2361,7 @@ pmc_thread_descriptor_pool_free_task(void *arg __unused) /* If there are entries to free, free them. */ while (!LIST_EMPTY(&tmplist)) { - pt = LIST_FIRST(&pmc_threadfreelist); + pt = LIST_FIRST(&tmplist); LIST_REMOVE(pt, pt_next); free(pt, M_PMC); }