Index: head/sys/kern/kern_timeout.c =================================================================== --- head/sys/kern/kern_timeout.c +++ head/sys/kern/kern_timeout.c @@ -1075,6 +1075,9 @@ WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, c->c_lock, "calling %s", __func__); + KASSERT((flags & CS_DRAIN) == 0 || drain == NULL, + ("Cannot set drain callback and CS_DRAIN flag at the same time")); + /* * Some old subsystems don't hold Giant while running a callout_stop(), * so just discard this check for the moment. @@ -1270,11 +1273,12 @@ } CC_UNLOCK(cc); return ((flags & CS_EXECUTING) != 0); - } - CTR3(KTR_CALLOUT, "failed to stop %p func %p arg %p", - c, c->c_func, c->c_arg); - if (drain) { - cc_exec_drain(cc, direct) = drain; + } else { + CTR3(KTR_CALLOUT, "failed to stop %p func %p arg %p", + c, c->c_func, c->c_arg); + if (drain) { + cc_exec_drain(cc, direct) = drain; + } } KASSERT(!sq_locked, ("sleepqueue chain still locked")); cancelled = ((flags & CS_EXECUTING) != 0);