Module Name: src
Committed By: christos
Date: Fri Dec 16 16:03:28 UTC 2016
Modified Files:
src/sys/dev: audio.c
Log Message:
On failed attach hw_if is NULL, so guard against it in more places. Should
avoid crashes people have been seeing recently.
To generate a diff of this commit:
cvs rdiff -u -r1.279 -r1.280 src/sys/dev/audio.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/dev/audio.c
diff -u src/sys/dev/audio.c:1.279 src/sys/dev/audio.c:1.280
--- src/sys/dev/audio.c:1.279 Thu Dec 15 17:01:57 2016
+++ src/sys/dev/audio.c Fri Dec 16 11:03:28 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: audio.c,v 1.279 2016/12/15 22:01:57 pgoyette Exp $ */
+/* $NetBSD: audio.c,v 1.280 2016/12/16 16:03:28 christos Exp $ */
/*-
* Copyright (c) 2016 Nathanial Sloss <[email protected]>
@@ -148,7 +148,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.279 2016/12/15 22:01:57 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.280 2016/12/16 16:03:28 christos Exp $");
#include "audio.h"
#if NAUDIO > 0
@@ -2177,6 +2177,8 @@ audio_close(struct audio_softc *sc, int
vc = sc->sc_vchan[n];
hw = sc->hw_if;
+ if (hw == NULL)
+ return ENXIO;
mutex_enter(sc->sc_intr_lock);
DPRINTF(("audio_close: sc=%p\n", sc));
/* Stop recording. */
@@ -2269,6 +2271,8 @@ audio_read(struct audio_softc *sc, struc
if (m == VAUDIOCHANS)
return EINVAL;
+ if (sc->hw_if == NULL)
+ return ENXIO;
vc = sc->sc_vchan[m];
cb = &vc->sc_mrr;
@@ -2600,6 +2604,9 @@ audio_write(struct audio_softc *sc, stru
if (n == VAUDIOCHANS)
return EINVAL;
+ if (sc->hw_if == NULL)
+ return ENXIO;
+
vc = sc->sc_vchan[n];
cb = &vc->sc_mpr;
@@ -2773,6 +2780,8 @@ audio_ioctl(dev_t dev, struct audio_soft
DPRINTF(("audio_ioctl(%lu,'%c',%lu)\n",
IOCPARM_LEN(cmd), (char)IOCGROUP(cmd), cmd&0xff));
hw = sc->hw_if;
+ if (hw == NULL)
+ return ENXIO;
error = 0;
switch (cmd) {
case AUDIO_SETPROC:
@@ -3141,6 +3150,9 @@ audio_mmap(struct audio_softc *sc, off_t
if (n == VAUDIOCHANS)
return -1;
+ if (sc->hw_if == NULL)
+ return ENXIO;
+
DPRINTF(("audio_mmap: off=%lld, prot=%d\n", (long long)off, prot));
vc = sc->sc_vchan[n];
if (!(audio_get_props(sc) & AUDIO_PROP_MMAP))
@@ -4759,6 +4771,8 @@ mixer_close(struct audio_softc *sc, int
{
KASSERT(mutex_owned(sc->sc_lock));
+ if (sc->hw_if == NULL)
+ return ENXIO;
DPRINTF(("mixer_close: sc %p\n", sc));
mixer_remove(sc);
@@ -4777,6 +4791,8 @@ mixer_ioctl(struct audio_softc *sc, u_lo
DPRINTF(("mixer_ioctl(%lu,'%c',%lu)\n",
IOCPARM_LEN(cmd), (char)IOCGROUP(cmd), cmd&0xff));
hw = sc->hw_if;
+ if (hw == NULL)
+ return ENXIO;
error = EINVAL;
/* we can return cached values if we are sleeping */