From 64bf9fe9fa4ffdff0c7bb06726e70267970c7f02 Mon Sep 17 00:00:00 2001 From: jhb Date: Wed, 20 Mar 2002 21:00:50 +0000 Subject: - Push down Giant into crfree() in the case that we actually free a ucred. - Add a cred_free_thread() function (conditional on DIAGNOSTICS) that drops a per-thread ucred reference to be used in debugging code when leaving the kernel. --- sys/kern/kern_prot.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'sys/kern/kern_prot.c') diff --git a/sys/kern/kern_prot.c b/sys/kern/kern_prot.c index 90f5196..a259919 100644 --- a/sys/kern/kern_prot.c +++ b/sys/kern/kern_prot.c @@ -1699,6 +1699,7 @@ crfree(cr) * allocate a uidinfo structure. */ mtx_unlock(mtxp); + mtx_lock(&Giant); if (cr->cr_uidinfo != NULL) uifree(cr->cr_uidinfo); if (cr->cr_ruidinfo != NULL) @@ -1709,6 +1710,7 @@ crfree(cr) if (jailed(cr)) prison_free(cr->cr_prison); FREE((caddr_t)cr, M_CRED); + mtx_unlock(&Giant); } else { mtx_unlock(mtxp); } @@ -1761,6 +1763,19 @@ crdup(cr) return (newcr); } +#ifdef DIAGNOSTIC +void +cred_free_thread(struct thread *td) +{ + struct ucred *cred; + + cred = td->td_ucred; + td->td_ucred = NULL; + if (cred != NULL) + crfree(cred); +} +#endif + /* * Fill in a struct xucred based on a struct ucred. */ -- cgit v1.1