summaryrefslogtreecommitdiffstats
path: root/sys/dev/random
diff options
context:
space:
mode:
authormarkm <markm@FreeBSD.org>2004-04-12 09:13:24 +0000
committermarkm <markm@FreeBSD.org>2004-04-12 09:13:24 +0000
commit7743e85352d8cc442bc06654035aa8c79237bdba (patch)
tree90bb3b6673820fc06eb0e3f24139a870667102db /sys/dev/random
parenta9c2757cc6ca1a1e206270893df08349ce3bcacc (diff)
downloadFreeBSD-src-7743e85352d8cc442bc06654035aa8c79237bdba.zip
FreeBSD-src-7743e85352d8cc442bc06654035aa8c79237bdba.tar.gz
Fix "sleeping without a mutex" panic.
Diffstat (limited to 'sys/dev/random')
-rw-r--r--sys/dev/random/randomdev.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/sys/dev/random/randomdev.c b/sys/dev/random/randomdev.c
index 63af98a..268159a 100644
--- a/sys/dev/random/randomdev.c
+++ b/sys/dev/random/randomdev.c
@@ -103,25 +103,28 @@ random_read(dev_t dev __unused, struct uio *uio, int flag)
{
int c, error = 0;
+ mtx_lock(&random_systat.lock);
+
/* Blocking logic */
while (!random_systat.seeded && !error) {
if (flag & IO_NDELAY)
error = EWOULDBLOCK;
else
- error = tsleep(&random_systat,
+ error = msleep(&random_systat, &random_systat.lock,
PUSER | PCATCH, "block", 0);
}
/* The actual read */
if (!error) {
- mtx_lock(&random_systat.lock);
while (uio->uio_resid > 0 && !error) {
c = MIN(uio->uio_resid, PAGE_SIZE);
c = (*random_systat.read)(random_buf, c);
error = uiomove(random_buf, c, uio);
}
- mtx_unlock(&random_systat.lock);
}
+
+ mtx_unlock(&random_systat.lock);
+
return (error);
}
OpenPOWER on IntegriCloud