Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev Remove dead code from audio open. Found by isaki@.



details:   https://anonhg.NetBSD.org/src/rev/de5dd45ece76
branches:  trunk
changeset: 355377:de5dd45ece76
user:      nat <nat%NetBSD.org@localhost>
date:      Fri Jul 28 03:58:54 2017 +0000

description:
Remove dead code from audio open.  Found by isaki@.
Better error handling incase memory for the streams' ringbuffers cannot be
allocated.

Addresses PR kern/52433.

diffstat:

 sys/dev/audio.c |  13 ++++---------
 1 files changed, 4 insertions(+), 9 deletions(-)

diffs (41 lines):

diff -r 1520f238cccd -r de5dd45ece76 sys/dev/audio.c
--- a/sys/dev/audio.c   Fri Jul 28 03:29:19 2017 +0000
+++ b/sys/dev/audio.c   Fri Jul 28 03:58:54 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: audio.c,v 1.374 2017/07/28 03:29:19 nat Exp $  */
+/*     $NetBSD: audio.c,v 1.375 2017/07/28 03:58:54 nat Exp $  */
 
 /*-
  * Copyright (c) 2016 Nathanial Sloss <nathanialsloss%yahoo.com.au@localhost>
@@ -148,7 +148,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.374 2017/07/28 03:29:19 nat Exp $");
+__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.375 2017/07/28 03:58:54 nat Exp $");
 
 #ifdef _KERNEL_OPT
 #include "audio.h"
@@ -2164,13 +2164,6 @@
        DPRINTF(("audio_open: flags=0x%x sc=%p hdl=%p\n",
                 flags, sc, sc->hw_hdl));
 
-       if (((flags & FREAD) && (vc->sc_open & AUOPEN_READ)) ||
-           ((flags & FWRITE) && (vc->sc_open & AUOPEN_WRITE))) {
-               kmem_free(vc, sizeof(struct virtual_channel));
-               kmem_free(chan, sizeof(struct audio_chan));
-               return EBUSY;
-       }
-
        error = audio_alloc_ring(sc, &vc->sc_mpr,
                    AUMODE_PLAY, AU_RING_SIZE);
        if (!error) {
@@ -2178,6 +2171,8 @@
                    AUMODE_RECORD, AU_RING_SIZE);
        }
        if (error) {
+               audio_free_ring(sc, &vc->sc_mrr);
+               audio_free_ring(sc, &vc->sc_mpr);
                kmem_free(vc, sizeof(struct virtual_channel));
                kmem_free(chan, sizeof(struct audio_chan));
                return error;



Home | Main Index | Thread Index | Old Index