Author: mmacy
Date: Mon May 28 23:16:39 2018
New Revision: 334300
URL: https://svnweb.freebsd.org/changeset/base/334300

Log:
  hwmpc: fix brain-damaged handling of thread descriptor freeing

Modified:
  head/sys/dev/hwpmc/hwpmc_mod.c

Modified: head/sys/dev/hwpmc/hwpmc_mod.c
==============================================================================
--- head/sys/dev/hwpmc/hwpmc_mod.c      Mon May 28 23:14:38 2018        
(r334299)
+++ head/sys/dev/hwpmc/hwpmc_mod.c      Mon May 28 23:16:39 2018        
(r334300)
@@ -2351,9 +2351,9 @@ pmc_thread_descriptor_pool_free_task(void *arg __unuse
        /* 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 __unuse
 
        /* 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);
        }
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to