diff options
Diffstat (limited to 'sys/dev/sound/pcm/sndstat.c')
-rw-r--r-- | sys/dev/sound/pcm/sndstat.c | 25 |
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 |