FreeBSD/sys/kern/kern_conf.c
/*
 * Free all the memory collected while the cdev mutex was
 * locked. Since devmtx is after the system map mutex, free() cannot
 * be called immediately and is postponed until cdev mutex can be
 * dropped.
 */
Free all the memory collected while the cdev mutex was
locked. Since devmtx is after the system map mutex, free() cannot
be called immediately and is postponed until cdev mutex can be
dropped.
Free all the memory collected while the cdev mutex was locked . Since devmtx is after the system map mutex free () cannot be called immediately and is postponed until cdev mutex can be dropped .
static void
dev_unlock_and_free(void)
{
	struct cdev_priv_list cdp_free;
	struct free_cdevsw csw_free;
	struct cdev_priv *cdp;
	struct cdevsw *csw;
	mtx_assert(&devmtx, MA_OWNED);
	TAILQ_INIT(&cdp_free);
	TAILQ_CONCAT(&cdp_free, &cdevp_free_list, cdp_list);
	csw_free = cdevsw_gt_post_list;
	SLIST_INIT(&cdevsw_gt_post_list);
	mtx_unlock(&devmtx);
	while ((cdp = TAILQ_FIRST(&cdp_free)) != NULL) {
		TAILQ_REMOVE(&cdp_free, cdp, cdp_list);
		devfs_free(&cdp->cdp_c);
	}
	while ((csw = SLIST_FIRST(&csw_free)) != NULL) {
		SLIST_REMOVE_HEAD(&csw_free, d_postfree_list);
		free(csw, M_DEVT);
	}
}
static void dev_unlock_and_free ( void ) { struct cdev_priv_list cdp_free ; struct free_cdevsw csw_free ; struct cdev_priv * cdp ; struct cdevsw * csw ; mtx_assert ( & devmtx , MA_OWNED ) ; TAILQ_INIT ( & cdp_free ) ; TAILQ_CONCAT ( & cdp_free , & cdevp_free_list , cdp_list ) ; csw_free = cdevsw_gt_post_list ; SLIST_INIT ( & cdevsw_gt_post_list ) ; mtx_unlock ( & devmtx ) ; while ( ( cdp = TAILQ_FIRST ( & cdp_free ) ) != NULL ) { TAILQ_REMOVE ( & cdp_free , cdp , cdp_list ) ; devfs_free ( & cdp -> cdp_c ) ; } while ( ( csw = SLIST_FIRST ( & csw_free ) ) != NULL ) { SLIST_REMOVE_HEAD ( & csw_free , d_postfree_list ) ; free ( csw , M_DEVT ) ; } }
Free all the memory collected while the cdev mutex was
 locked.
Free all the memory collected while the cdev mutex was locked .
/*
	 * Make the local copy of the list heads while the dev_mtx is
	 * held. Free it later.
	 */