Module Name: src Committed By: simonb Date: Thu Apr 8 06:06:24 UTC 2021
Modified Files: src/sys/kern: kern_tc.c Log Message: tc_init(): KASSERT that the timecounter hasn't previously been initialised by checking the tc_next field. Prevents nastly endless loops in the timecounter code. To generate a diff of this commit: cvs rdiff -u -r1.59 -r1.60 src/sys/kern/kern_tc.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_tc.c diff -u src/sys/kern/kern_tc.c:1.59 src/sys/kern/kern_tc.c:1.60 --- src/sys/kern/kern_tc.c:1.59 Wed May 27 09:09:50 2020 +++ src/sys/kern/kern_tc.c Thu Apr 8 06:06:24 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: kern_tc.c,v 1.59 2020/05/27 09:09:50 rin Exp $ */ +/* $NetBSD: kern_tc.c,v 1.60 2021/04/08 06:06:24 simonb Exp $ */ /*- * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc. @@ -40,7 +40,7 @@ #include <sys/cdefs.h> /* __FBSDID("$FreeBSD: src/sys/kern/kern_tc.c,v 1.166 2005/09/19 22:16:31 andre Exp $"); */ -__KERNEL_RCSID(0, "$NetBSD: kern_tc.c,v 1.59 2020/05/27 09:09:50 rin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_tc.c,v 1.60 2021/04/08 06:06:24 simonb Exp $"); #ifdef _KERNEL_OPT #include "opt_ntp.h" @@ -551,6 +551,9 @@ tc_init(struct timecounter *tc) { u_int u; + KASSERTMSG(tc->tc_next == NULL, "timecounter %s already initialised", + tc->tc_name); + u = tc->tc_frequency / tc->tc_counter_mask; /* XXX: We need some margin here, 10% is a guess */ u *= 11;