aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOrion Hodson <orion@FreeBSD.org>2003-05-01 16:31:21 +0000
committerOrion Hodson <orion@FreeBSD.org>2003-05-01 16:31:21 +0000
commit4f3204ef222dc8ac1e2d902ed3a212e7931cdcd7 (patch)
treed03c67c153056249303290f57413b28eb7090f56
parent8b3e7e90f25071746fc23912ba43af6283eea399 (diff)
downloadsrc-4f3204ef222dc8ac1e2d902ed3a212e7931cdcd7.tar.gz
src-4f3204ef222dc8ac1e2d902ed3a212e7931cdcd7.zip
Fix lock order reversal when opening device and chn_reset fails.
Submitted by: Jan-Espen Pettersen <sigsegv@leakingmemory.org> Tested by: Georg Funk <georgfunk@web.de>
Notes
Notes: svn path=/head/; revision=114432
-rw-r--r--sys/dev/sound/pcm/dsp.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/sys/dev/sound/pcm/dsp.c b/sys/dev/sound/pcm/dsp.c
index 65ff15061dee..04622d29c365 100644
--- a/sys/dev/sound/pcm/dsp.c
+++ b/sys/dev/sound/pcm/dsp.c
@@ -262,13 +262,12 @@ dsp_open(dev_t i_dev, int flags, int mode, struct thread *td)
i_dev->si_drv1 = rdch;
i_dev->si_drv2 = wrch;
- pcm_unlock(d);
- /* finished with snddev, new channels still locked */
- /* bump refcounts, reset and unlock any channels that we just opened */
+ /* Bump refcounts, reset and unlock any channels that we just opened,
+ * and then release device lock.
+ */
if (flags & FREAD) {
if (chn_reset(rdch, fmt)) {
- pcm_lock(d);
pcm_chnrelease(rdch);
i_dev->si_drv1 = NULL;
if (wrch && (flags & FWRITE)) {
@@ -286,7 +285,6 @@ dsp_open(dev_t i_dev, int flags, int mode, struct thread *td)
}
if (flags & FWRITE) {
if (chn_reset(wrch, fmt)) {
- pcm_lock(d);
pcm_chnrelease(wrch);
i_dev->si_drv2 = NULL;
if (flags & FREAD) {
@@ -304,6 +302,7 @@ dsp_open(dev_t i_dev, int flags, int mode, struct thread *td)
pcm_chnref(wrch, 1);
CHN_UNLOCK(wrch);
}
+ pcm_unlock(d);
splx(s);
return 0;
}