Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/kern add DIAGNOSTIC check for rnd_attach_source() being ...
details: https://anonhg.NetBSD.org/src/rev/d7a8547d9fc6
branches: trunk
changeset: 362963:d7a8547d9fc6
user: jdolecek <jdolecek%NetBSD.org@localhost>
date: Tue Jul 03 18:09:28 2018 +0000
description:
add DIAGNOSTIC check for rnd_attach_source() being called twice for same
rnd source; it's driver error, and it breaks rnd source list pointers
diffstat:
sys/kern/kern_rndq.c | 16 ++++++++++++++--
1 files changed, 14 insertions(+), 2 deletions(-)
diffs (37 lines):
diff -r 61c534ba8812 -r d7a8547d9fc6 sys/kern/kern_rndq.c
--- a/sys/kern/kern_rndq.c Tue Jul 03 18:07:36 2018 +0000
+++ b/sys/kern/kern_rndq.c Tue Jul 03 18:09:28 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: kern_rndq.c,v 1.89 2016/05/21 15:27:15 riastradh Exp $ */
+/* $NetBSD: kern_rndq.c,v 1.90 2018/07/03 18:09:28 jdolecek Exp $ */
/*-
* Copyright (c) 1997-2013 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_rndq.c,v 1.89 2016/05/21 15:27:15 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_rndq.c,v 1.90 2018/07/03 18:09:28 jdolecek Exp $");
#include <sys/param.h>
#include <sys/atomic.h>
@@ -747,6 +747,18 @@
rs->state = rnd_sample_allocate(rs);
mutex_spin_enter(&rnd_global.lock);
+
+#ifdef DIAGNOSTIC
+ krndsource_t *s;
+ LIST_FOREACH(s, &rnd_global.sources, list) {
+ if (s == rs) {
+ panic("%s: source '%s' already attached",
+ __func__, name);
+ /* NOTREACHED */
+ }
+ }
+#endif
+
LIST_INSERT_HEAD(&rnd_global.sources, rs, list);
#ifdef RND_VERBOSE
Home |
Main Index |
Thread Index |
Old Index