diff options
| author | augustss <augustss@NetBSD.org> | 1997-07-27 23:06:04 +0000 |
|---|---|---|
| committer | augustss <augustss@NetBSD.org> | 1997-07-27 23:06:04 +0000 |
| commit | 63decd94381c63d26ed2d9c899735d9ec9aac7e8 (patch) | |
| tree | 9f012a816feec1881164ae4fbb58ad204c35e552 /sys/dev | |
| parent | f18d1df87b5288464d5e947f793853ce48a48000 (diff) | |
Fix divide by 0 bug in audio driver.
Diffstat (limited to 'sys/dev')
| -rw-r--r-- | sys/dev/audio.c | 10 | ||||
| -rw-r--r-- | sys/dev/audiovar.h | 3 |
2 files changed, 9 insertions, 4 deletions
diff --git a/sys/dev/audio.c b/sys/dev/audio.c index 9f4f2468b09..61e1bdb7114 100644 --- a/sys/dev/audio.c +++ b/sys/dev/audio.c @@ -1,4 +1,4 @@ -/* $NetBSD: audio.c,v 1.52 1997/07/27 01:16:44 augustss Exp $ */ +/* $NetBSD: audio.c,v 1.53 1997/07/27 23:06:04 augustss Exp $ */ /* * Copyright (c) 1991-1993 Regents of the University of California. @@ -471,6 +471,8 @@ audio_init_ringbuffer(rp) int nblks; int blksize = rp->blksize; + if (blksize < AUMINBLK) + blksize = AUMINBLK; nblks = rp->bufsize / blksize; if (nblks < AUMINNOBLK) { nblks = AUMINNOBLK; @@ -1511,10 +1513,9 @@ audio_pint(v) struct audio_hw_if *hw = sc->hw_if; struct audio_ringbuffer *cb = &sc->sc_pr; u_char *inp; - int cc, n; + int cc; int error; - n = (cb->outp - cb->start) / cb->blksize; cb->outp += cb->blksize; if (cb->outp >= cb->end) cb->outp = cb->start; @@ -1759,6 +1760,9 @@ audio_check_params(p) return (EINVAL); } + if (p->channels < 1 || p->channels > 8) /* sanity check # of channels */ + return (EINVAL); + return (0); } diff --git a/sys/dev/audiovar.h b/sys/dev/audiovar.h index 8a33af81efe..aa0ac2959af 100644 --- a/sys/dev/audiovar.h +++ b/sys/dev/audiovar.h @@ -1,4 +1,4 @@ -/* $NetBSD: audiovar.h,v 1.11 1997/07/27 01:16:47 augustss Exp $ */ +/* $NetBSD: audiovar.h,v 1.12 1997/07/27 23:06:05 augustss Exp $ */ /* * Copyright (c) 1991-1993 Regents of the University of California. @@ -47,6 +47,7 @@ #endif #define AUMINBUF 512 +#define AUMINBLK 32 #define AUMINNOBLK 3 struct audio_ringbuffer { int bufsize; /* allocated memory */ |
