summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorNiklas Hallqvist <niklas@cvs.openbsd.org>1996-12-28 19:06:29 +0000
committerNiklas Hallqvist <niklas@cvs.openbsd.org>1996-12-28 19:06:29 +0000
commit32b0ab1dfbb2689bc0af2c4380d48acf2a2211d2 (patch)
tree560954dbec9c4d23cbed5e37f72a1d488a845405 /sys
parentbc85a78c91804738ab2b62ffe79726381935c7ba (diff)
Fix prerequisite test, still need to check why NODEV bufs comes here.
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/rnd.c30
1 files changed, 25 insertions, 5 deletions
diff --git a/sys/dev/rnd.c b/sys/dev/rnd.c
index 60e3f938332..cb912b4327d 100644
--- a/sys/dev/rnd.c
+++ b/sys/dev/rnd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rnd.c,v 1.11 1996/10/19 13:25:58 mickey Exp $ */
+/* $OpenBSD: rnd.c,v 1.12 1996/12/28 19:06:28 niklas Exp $ */
/*
* random.c -- A strong random number generator
@@ -402,10 +402,10 @@ randomattach(void)
random_state.entropy_count = 0;
random_state.pool = random_pool;
blkdev_timer_state = malloc(nblkdev*sizeof(*blkdev_timer_state),
- M_DEVBUF, M_WAITOK);
+ M_DEVBUF, M_WAITOK);
bzero(blkdev_timer_state, nblkdev*sizeof(*blkdev_timer_state));
tty_timer_state = malloc(nchrdev*sizeof(*tty_timer_state),
- M_DEVBUF, M_WAITOK);
+ M_DEVBUF, M_WAITOK);
bzero(tty_timer_state, nchrdev*sizeof(*tty_timer_state));
extract_timer_state.dont_count_entropy = 1;
@@ -570,9 +570,18 @@ void
add_blkdev_randomness(dev)
dev_t dev;
{
- if (major(dev) <= nblkdev || blkdev_timer_state == NULL)
+ /*
+ * Happens before randomattach() has been run and then later
+ * when NODEV buffers get fed to biodone(). XXX Howcome?
+ */
+ if (dev == NODEV || blkdev_timer_state == NULL)
return;
+#ifdef DIAGNOSTIC
+ if (major(dev) >= nblkdev)
+ panic("add_blkdev_randomness(dev = 0x%x): bad device", dev);
+#endif
+
add_timer_randomness(&random_state, &blkdev_timer_state[major(dev)],
ENT_BLKDEV + major(dev));
}
@@ -582,9 +591,20 @@ add_tty_randomness(dev, c)
dev_t dev;
int c;
{
- if (major(dev) <= nchrdev || tty_timer_state == NULL)
+ /*
+ * XXX does this routine ever get called before randomattach?
+ * Well, this is a safety belt against that condition. Should
+ * we check for NODEV too, like in the block device case?
+ */
+ if (tty_timer_state == NULL)
return;
+#ifdef DIAGNOSTIC
+ if (major(dev) >= nchrdev)
+ panic("add_tty_randomness(dev = 0x%x, c = %d): bad device",
+ dev, c);
+#endif
+
add_timer_randomness(&random_state, &tty_timer_state[major(dev)],
ENT_TTY + c);
}