Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/audio audio(4): Set AUMODE_PLAY/RECORD only if asked...
details: https://anonhg.NetBSD.org/src/rev/96611e6fc109
branches: trunk
changeset: 379463:96611e6fc109
user: riastradh <riastradh%NetBSD.org@localhost>
date: Tue Jun 01 21:12:24 2021 +0000
description:
audio(4): Set AUMODE_PLAY/RECORD only if asked _and_ supported.
If one is requested and _not_ supported, fail; otherwise we might
enter audio_write with a null play track and crash on KASSERT.
diffstat:
sys/dev/audio/audio.c | 18 ++++++++++++++----
1 files changed, 14 insertions(+), 4 deletions(-)
diffs (41 lines):
diff -r 3a19cf2065c2 -r 96611e6fc109 sys/dev/audio/audio.c
--- a/sys/dev/audio/audio.c Tue Jun 01 21:11:52 2021 +0000
+++ b/sys/dev/audio/audio.c Tue Jun 01 21:12:24 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: audio.c,v 1.95 2021/05/02 21:37:32 nia Exp $ */
+/* $NetBSD: audio.c,v 1.96 2021/06/01 21:12:24 riastradh Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -138,7 +138,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.95 2021/05/02 21:37:32 nia Exp $");
+__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.96 2021/06/01 21:12:24 riastradh Exp $");
#ifdef _KERNEL_OPT
#include "audio.h"
@@ -2237,10 +2237,20 @@ audio_open(dev_t dev, struct audio_softc
af = kmem_zalloc(sizeof(audio_file_t), KM_SLEEP);
af->sc = sc;
af->dev = dev;
- if ((flags & FWRITE) != 0 && audio_can_playback(sc))
+ if (flags & FWRITE) {
+ if (!audio_can_playback(sc)) {
+ error = ENXIO;
+ goto bad;
+ }
af->mode |= AUMODE_PLAY | AUMODE_PLAY_ALL;
- if ((flags & FREAD) != 0 && audio_can_capture(sc))
+ }
+ if (flags & FREAD) {
+ if (!audio_can_capture(sc)) {
+ error = ENXIO;
+ goto bad;
+ }
af->mode |= AUMODE_RECORD;
+ }
if (af->mode == 0) {
error = ENXIO;
goto bad;
Home |
Main Index |
Thread Index |
Old Index