summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexandre Ratchov <ratchov@cvs.openbsd.org>2016-12-08 17:23:34 +0000
committerAlexandre Ratchov <ratchov@cvs.openbsd.org>2016-12-08 17:23:34 +0000
commit15de74750099f64d786f4b9a2dcce0f0a5d7fef1 (patch)
treef13224ba1dfabc7ed0e93bfe89010a175bfd0c2c
parent3efea1df3501f974a5175c9d083e5eac8f29ca7e (diff)
Return ENODEV if playback is requested on devices with no DACs or
recording is requested on devices with no ADCs. Many thanks to Bryan Vyhmeister <bryan at bsdjournal.net> for testing & debugging this.
-rw-r--r--sys/dev/pci/azalia.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/sys/dev/pci/azalia.c b/sys/dev/pci/azalia.c
index 57ee558e308..50697901e2d 100644
--- a/sys/dev/pci/azalia.c
+++ b/sys/dev/pci/azalia.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: azalia.c,v 1.229 2016/09/19 06:46:44 ratchov Exp $ */
+/* $OpenBSD: azalia.c,v 1.230 2016/12/08 17:23:33 ratchov Exp $ */
/* $NetBSD: azalia.c,v 1.20 2006/05/07 08:31:44 kent Exp $ */
/*-
@@ -41,6 +41,7 @@
*/
#include <sys/param.h>
+#include <sys/fcntl.h>
#include <sys/device.h>
#include <sys/malloc.h>
#include <sys/systm.h>
@@ -3842,6 +3843,10 @@ azalia_open(void *v, int flags)
DPRINTFN(1, ("%s: flags=0x%x\n", __func__, flags));
az = v;
codec = &az->codecs[az->codecno];
+ if ((flags & FWRITE) && codec->dacs.ngroups == 0)
+ return ENODEV;
+ if ((flags & FREAD) && codec->adcs.ngroups == 0)
+ return ENODEV;
codec->running++;
return 0;
}