summaryrefslogtreecommitdiffstats
path: root/sys/dev/sound/pcm/sndstat.c
diff options
context:
space:
mode:
authorgreen <green@FreeBSD.org>2002-07-25 04:49:45 +0000
committergreen <green@FreeBSD.org>2002-07-25 04:49:45 +0000
commitde2cfb0a7a345b657b83e8a56d35a723fc436192 (patch)
tree5c72f4c9c3de7b3c307d1b3e261f39f93e56ad6a /sys/dev/sound/pcm/sndstat.c
parent891c9fcb896ad87afa576f252cb60c125f96ac38 (diff)
downloadFreeBSD-src-de2cfb0a7a345b657b83e8a56d35a723fc436192.zip
FreeBSD-src-de2cfb0a7a345b657b83e8a56d35a723fc436192.tar.gz
Fix some of the places where sound(4) can sleep with a lock held. (Help
courtesy of fenner).
Diffstat (limited to 'sys/dev/sound/pcm/sndstat.c')
-rw-r--r--sys/dev/sound/pcm/sndstat.c25
1 files changed, 15 insertions, 10 deletions
diff --git a/sys/dev/sound/pcm/sndstat.c b/sys/dev/sound/pcm/sndstat.c
index 5ff2080..bd9cb32 100644
--- a/sys/dev/sound/pcm/sndstat.c
+++ b/sys/dev/sound/pcm/sndstat.c
@@ -112,7 +112,7 @@ static int
sndstat_open(dev_t i_dev, int flags, int mode, struct thread *td)
{
intrmask_t s;
- int err;
+ int error;
s = spltty();
mtx_lock(&sndstat_lock);
@@ -121,19 +121,24 @@ sndstat_open(dev_t i_dev, int flags, int mode, struct thread *td)
splx(s);
return EBUSY;
}
+ sndstat_isopen = 1;
+ mtx_unlock(&sndstat_lock);
+ splx(s);
if (sbuf_new(&sndstat_sbuf, NULL, 4096, 0) == NULL) {
+ error = ENXIO;
+ goto out;
+ }
+ sndstat_bufptr = 0;
+ error = (sndstat_prepare(&sndstat_sbuf) > 0) ? 0 : ENOMEM;
+out:
+ if (error) {
+ s = spltty();
+ mtx_lock(&sndstat_lock);
+ sndstat_isopen = 0;
mtx_unlock(&sndstat_lock);
splx(s);
- return ENXIO;
}
- sndstat_bufptr = 0;
- err = (sndstat_prepare(&sndstat_sbuf) > 0)? 0 : ENOMEM;
- if (!err)
- sndstat_isopen = 1;
-
- mtx_unlock(&sndstat_lock);
- splx(s);
- return err;
+ return (error);
}
static int
OpenPOWER on IntegriCloud