Module Name:    src
Committed By:   christos
Date:           Tue Jan  9 01:44:50 UTC 2018

Modified Files:
        src/sys/kern: kern_timeout.c

Log Message:
check the magic first in case we got passed a junk pointer.


To generate a diff of this commit:
cvs rdiff -u -r1.52 -r1.53 src/sys/kern/kern_timeout.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/kern/kern_timeout.c
diff -u src/sys/kern/kern_timeout.c:1.52 src/sys/kern/kern_timeout.c:1.53
--- src/sys/kern/kern_timeout.c:1.52	Wed May 31 22:45:13 2017
+++ src/sys/kern/kern_timeout.c	Mon Jan  8 20:44:50 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_timeout.c,v 1.52 2017/06/01 02:45:13 chs Exp $	*/
+/*	$NetBSD: kern_timeout.c,v 1.53 2018/01/09 01:44:50 christos Exp $	*/
 
 /*-
  * Copyright (c) 2003, 2006, 2007, 2008, 2009 The NetBSD Foundation, Inc.
@@ -59,7 +59,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_timeout.c,v 1.52 2017/06/01 02:45:13 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_timeout.c,v 1.53 2018/01/09 01:44:50 christos Exp $");
 
 /*
  * Timeouts are kept in a hierarchical timing wheel.  The c_time is the
@@ -304,6 +304,9 @@ callout_destroy(callout_t *cs)
 {
 	callout_impl_t *c = (callout_impl_t *)cs;
 
+	KASSERTMSG(c->c_magic == CALLOUT_MAGIC,
+	    "callout %p: c_magic (%#x) != CALLOUT_MAGIC (%#x)",
+	    c, c->c_magic, CALLOUT_MAGIC);
 	/*
 	 * It's not necessary to lock in order to see the correct value
 	 * of c->c_flags.  If the callout could potentially have been
@@ -313,9 +316,6 @@ callout_destroy(callout_t *cs)
 	    "callout %p: c_func (%p) c_flags (%#x) destroyed from %p",
 	    c, c->c_func, c->c_flags, __builtin_return_address(0));
 	KASSERT(c->c_cpu->cc_lwp == curlwp || c->c_cpu->cc_active != c);
-	KASSERTMSG(c->c_magic == CALLOUT_MAGIC,
-	    "callout %p: c_magic (%#x) != CALLOUT_MAGIC (%#x)",
-	    c, c->c_magic, CALLOUT_MAGIC);
 	c->c_magic = 0;
 }
 

Reply via email to