From 10bb45afc0a9286bb146666e2e29294916f5226d Mon Sep 17 00:00:00 2001 From: Sepherosa Ziehau Date: Tue, 10 Dec 2013 23:38:36 +0800 Subject: [PATCH] callout: Fix callout_terminate() if the callout_reset() is never called If callout_reset() is never called, then c_gd will be NULL --- sys/kern/kern_timeout.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/sys/kern/kern_timeout.c b/sys/kern/kern_timeout.c index aeeb27614c..4086737d84 100644 --- a/sys/kern/kern_timeout.c +++ b/sys/kern/kern_timeout.c @@ -583,10 +583,12 @@ callout_terminate(struct callout *c) if (c->c_flags & CALLOUT_DID_INIT) { callout_stop(c); - sc = &softclock_pcpu_ary[c->c_gd->gd_cpuid]; - if (sc->running == c) { - while (sc->running == c) - tsleep(&sc->running, 0, "crace", 1); + if (c->c_gd) { + sc = &softclock_pcpu_ary[c->c_gd->gd_cpuid]; + if (sc->running == c) { + while (sc->running == c) + tsleep(&sc->running, 0, "crace", 1); + } } KKASSERT((c->c_flags & (CALLOUT_PENDING|CALLOUT_ACTIVE)) == 0); c->c_flags &= ~CALLOUT_DID_INIT; -- 2.41.0