From 624677fad7b2f6d9467b3e2ecd85659d5ad145d6 Mon Sep 17 00:00:00 2001 From: Hans Petter Selasky Date: Wed, 2 Sep 2020 10:00:30 +0000 Subject: [PATCH] Assert that cc_exec_drain(cc, direct) is NULL before assigning a new value. Suggested by: markj@ Tested by: callout_test MFC after: 1 week Sponsored by: Mellanox Technologies // NVIDIA Networking --- sys/kern/kern_timeout.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/sys/kern/kern_timeout.c b/sys/kern/kern_timeout.c index 760491d8c21..dae56ad2d53 100644 --- a/sys/kern/kern_timeout.c +++ b/sys/kern/kern_timeout.c @@ -1269,6 +1269,9 @@ _callout_stop_safe(struct callout *c, int flags, callout_func_t *drain) CTR3(KTR_CALLOUT, "postponing stop %p func %p arg %p", c, c->c_func, c->c_arg); if (drain) { + KASSERT(cc_exec_drain(cc, direct) == NULL, + ("callout drain function already set to %p", + cc_exec_drain(cc, direct))); cc_exec_drain(cc, direct) = drain; } CC_UNLOCK(cc); @@ -1277,6 +1280,9 @@ _callout_stop_safe(struct callout *c, int flags, callout_func_t *drain) CTR3(KTR_CALLOUT, "failed to stop %p func %p arg %p", c, c->c_func, c->c_arg); if (drain) { + KASSERT(cc_exec_drain(cc, direct) == NULL, + ("callout drain function already set to %p", + cc_exec_drain(cc, direct))); cc_exec_drain(cc, direct) = drain; } } -- 2.45.0