From ee252fc9951a8d767400d797fb73964bbc9f738f Mon Sep 17 00:00:00 2001 From: Mateusz Guzik Date: Tue, 22 May 2018 15:13:25 +0000 Subject: [PATCH] sx: fixup a braino in r334024 If a thread waiting on sx dropped Giant it would not be properly reacquired on exit from the routine, later resulting in panics indicating Giant is not held (when it should be). The bug was not present in the original patch sent to pho, I wittingly added it just prior to the commit and only smoke-tested it. Reported by: pho --- sys/kern/kern_sx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/kern/kern_sx.c b/sys/kern/kern_sx.c index 064ad91718b..c1ebfb2f715 100644 --- a/sys/kern/kern_sx.c +++ b/sys/kern/kern_sx.c @@ -879,6 +879,7 @@ retry_sleepq: if (in_critical) critical_exit(); #endif + GIANT_RESTORE(); #if defined(KDTRACE_HOOKS) || defined(LOCK_PROFILING) if (__predict_true(!doing_lockprof)) return (error); @@ -898,7 +899,6 @@ out_lockstat: if (!error) LOCKSTAT_PROFILE_OBTAIN_RWLOCK_SUCCESS(sx__acquire, sx, contested, waittime, file, line, LOCKSTAT_WRITER); - GIANT_RESTORE(); return (error); }