diff --git a/sys/alpha/alpha/trap.c b/sys/alpha/alpha/trap.c index f4af4bab97c8..2114c67b7eae 100644 --- a/sys/alpha/alpha/trap.c +++ b/sys/alpha/alpha/trap.c @@ -596,6 +596,9 @@ trap(a0, a1, a2, entry, framep) framep->tf_regs[FRAME_SP] = alpha_pal_rdusp(); userret(td, framep, sticks); mtx_assert(&Giant, MA_NOTOWNED); +#ifdef DIAGNOSTIC + cred_free_thread(td); +#endif } return; @@ -799,6 +802,9 @@ syscall(code, framep) */ STOPEVENT(p, S_SCX, code); +#ifdef DIAGNOSTIC + cred_free_thread(td); +#endif #ifdef WITNESS if (witness_list(td)) { panic("system call %s returning with mutex(s) held\n", diff --git a/sys/amd64/amd64/trap.c b/sys/amd64/amd64/trap.c index fddb5176b365..474b16d80eeb 100644 --- a/sys/amd64/amd64/trap.c +++ b/sys/amd64/amd64/trap.c @@ -295,7 +295,7 @@ trap(frame) #ifdef DEV_NPX ucode = npxtrap(); if (ucode == -1) - goto out; + goto userout; #else ucode = code; #endif @@ -345,7 +345,7 @@ trap(frame) } #endif if (i == -1) - goto out; + goto userout; if (i == 0) goto user; @@ -370,7 +370,7 @@ trap(frame) lastalert = time_second; } mtx_unlock(&Giant); - goto out; + goto userout; #else /* !POWERFAIL_NMI */ /* machine/parity/power fail/"kitchen sink" faults */ /* XXX Giant */ @@ -385,7 +385,7 @@ trap(frame) kdb_trap (type, 0, &frame); } #endif /* DDB */ - goto out; + goto userout; } else if (panic_on_nmi) panic("NMI indicates hardware failure"); break; @@ -406,7 +406,7 @@ trap(frame) #ifdef DEV_NPX /* transparent fault (due to context switch "late") */ if (npxdna()) - goto out; + goto userout; #endif if (!pmath_emulate) { i = SIGFPE; @@ -418,7 +418,7 @@ trap(frame) mtx_unlock(&Giant); if (i == 0) { if (!(frame.tf_eflags & PSL_T)) - goto out; + goto userout; frame.tf_eflags &= ~PSL_T; i = SIGTRAP; } @@ -662,6 +662,10 @@ trap(frame) user: userret(td, &frame, sticks); mtx_assert(&Giant, MA_NOTOWNED); +userout: +#ifdef DIAGNOSTIC + cred_free_thread(td); +#endif out: return; } @@ -1106,6 +1110,10 @@ syscall(frame) */ STOPEVENT(p, S_SCX, code); +#ifdef DIAGNOSTIC + cred_free_thread(td); +#endif + #ifdef WITNESS if (witness_list(td)) { panic("system call %s returning with mutex(s) held\n", diff --git a/sys/i386/i386/trap.c b/sys/i386/i386/trap.c index fddb5176b365..474b16d80eeb 100644 --- a/sys/i386/i386/trap.c +++ b/sys/i386/i386/trap.c @@ -295,7 +295,7 @@ trap(frame) #ifdef DEV_NPX ucode = npxtrap(); if (ucode == -1) - goto out; + goto userout; #else ucode = code; #endif @@ -345,7 +345,7 @@ trap(frame) } #endif if (i == -1) - goto out; + goto userout; if (i == 0) goto user; @@ -370,7 +370,7 @@ trap(frame) lastalert = time_second; } mtx_unlock(&Giant); - goto out; + goto userout; #else /* !POWERFAIL_NMI */ /* machine/parity/power fail/"kitchen sink" faults */ /* XXX Giant */ @@ -385,7 +385,7 @@ trap(frame) kdb_trap (type, 0, &frame); } #endif /* DDB */ - goto out; + goto userout; } else if (panic_on_nmi) panic("NMI indicates hardware failure"); break; @@ -406,7 +406,7 @@ trap(frame) #ifdef DEV_NPX /* transparent fault (due to context switch "late") */ if (npxdna()) - goto out; + goto userout; #endif if (!pmath_emulate) { i = SIGFPE; @@ -418,7 +418,7 @@ trap(frame) mtx_unlock(&Giant); if (i == 0) { if (!(frame.tf_eflags & PSL_T)) - goto out; + goto userout; frame.tf_eflags &= ~PSL_T; i = SIGTRAP; } @@ -662,6 +662,10 @@ trap(frame) user: userret(td, &frame, sticks); mtx_assert(&Giant, MA_NOTOWNED); +userout: +#ifdef DIAGNOSTIC + cred_free_thread(td); +#endif out: return; } @@ -1106,6 +1110,10 @@ syscall(frame) */ STOPEVENT(p, S_SCX, code); +#ifdef DIAGNOSTIC + cred_free_thread(td); +#endif + #ifdef WITNESS if (witness_list(td)) { panic("system call %s returning with mutex(s) held\n", diff --git a/sys/ia64/ia64/trap.c b/sys/ia64/ia64/trap.c index 74dfebff7a43..254aec637e59 100644 --- a/sys/ia64/ia64/trap.c +++ b/sys/ia64/ia64/trap.c @@ -746,6 +746,9 @@ trap(int vector, int imm, struct trapframe *framep) if (user) { userret(td, framep, sticks); mtx_assert(&Giant, MA_NOTOWNED); +#ifdef DIAGNOSTIC + cred_free_thread(td); +#endif } return; @@ -915,6 +918,9 @@ syscall(int code, u_int64_t *args, struct trapframe *framep) */ STOPEVENT(p, S_SCX, code); +#ifdef DIAGNOSTIC + cred_free_thread(td); +#endif #ifdef WITNESS if (witness_list(td)) { panic("system call %s returning with mutex(s) held\n", @@ -1089,6 +1095,10 @@ ia32_syscall(struct trapframe *framep) */ STOPEVENT(p, S_SCX, code); +#ifdef DIAGNOSTIC + cred_free_thread(td); +#endif + #ifdef WITNESS if (witness_list(td)) { panic("system call %s returning with mutex(s) held\n", diff --git a/sys/powerpc/aim/trap.c b/sys/powerpc/aim/trap.c index 067eb3a91a13..e43e9ccbc1c1 100644 --- a/sys/powerpc/aim/trap.c +++ b/sys/powerpc/aim/trap.c @@ -269,6 +269,9 @@ trap(struct trapframe *frame) userret(td, frame, sticks); mtx_assert(&Giant, MA_NOTOWNED); +#ifdef DIAGNOSTIC + cred_free_thread(td); +#endif /* DIAGNOSTIC */ } static void diff --git a/sys/powerpc/powerpc/trap.c b/sys/powerpc/powerpc/trap.c index 067eb3a91a13..e43e9ccbc1c1 100644 --- a/sys/powerpc/powerpc/trap.c +++ b/sys/powerpc/powerpc/trap.c @@ -269,6 +269,9 @@ trap(struct trapframe *frame) userret(td, frame, sticks); mtx_assert(&Giant, MA_NOTOWNED); +#ifdef DIAGNOSTIC + cred_free_thread(td); +#endif /* DIAGNOSTIC */ } static void diff --git a/sys/sparc64/sparc64/trap.c b/sys/sparc64/sparc64/trap.c index 66fb14178304..0ab35afd053c 100644 --- a/sys/sparc64/sparc64/trap.c +++ b/sys/sparc64/sparc64/trap.c @@ -392,6 +392,9 @@ if ((type & ~T_KERNEL) != T_BREAKPOINT) user: userret(td, tf, sticks); mtx_assert(&Giant, MA_NOTOWNED); +#ifdef DIAGNOSTIC + cred_free_thread(td); +#endif out: CTR1(KTR_TRAP, "trap: td=%p return", td); return; @@ -680,6 +683,9 @@ syscall(struct trapframe *tf) */ STOPEVENT(p, S_SCX, code); +#ifdef DIAGNOSTIC + cred_free_thread(td); +#endif #ifdef WITNESS if (witness_list(td)) { panic("system call %s returning with mutex(s) held\n",