svn commit: r334300 - head/sys/dev/hwpmc

Matt Macy mmacy at FreeBSD.org
Mon May 28 23:16:40 UTC 2018


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);
 	}


More information about the svn-src-head mailing list