diff options
author | orion <orion@FreeBSD.org> | 2003-04-20 17:08:56 +0000 |
---|---|---|
committer | orion <orion@FreeBSD.org> | 2003-04-20 17:08:56 +0000 |
commit | 26bf26a8364945b1a8d703575c9016637f63e73f (patch) | |
tree | ca2af124c6f65c339d3eb396617dd1abc1c3357d /sys/dev | |
parent | 81d6b311020dc650aa2b900f7a08156ffecedba9 (diff) | |
download | FreeBSD-src-26bf26a8364945b1a8d703575c9016637f63e73f.zip FreeBSD-src-26bf26a8364945b1a8d703575c9016637f63e73f.tar.gz |
Additional malloc failure checks.
Diffstat (limited to 'sys/dev')
-rw-r--r-- | sys/dev/sound/pcm/buffer.c | 11 | ||||
-rw-r--r-- | sys/dev/sound/pcm/feeder_fmt.c | 6 | ||||
-rw-r--r-- | sys/dev/sound/pcm/feeder_rate.c | 2 |
3 files changed, 15 insertions, 4 deletions
diff --git a/sys/dev/sound/pcm/buffer.c b/sys/dev/sound/pcm/buffer.c index 8ae35a3..30e0996 100644 --- a/sys/dev/sound/pcm/buffer.c +++ b/sys/dev/sound/pcm/buffer.c @@ -113,6 +113,7 @@ sndbuf_free(struct snd_dbuf *b) int sndbuf_resize(struct snd_dbuf *b, unsigned int blkcnt, unsigned int blksz) { + u_int8_t *tmpbuf; if (b->maxsize == 0) return 0; if (blkcnt == 0) @@ -126,9 +127,12 @@ sndbuf_resize(struct snd_dbuf *b, unsigned int blkcnt, unsigned int blksz) b->blkcnt = blkcnt; b->blksz = blksz; b->bufsize = blkcnt * blksz; - if (b->tmpbuf) - free(b->tmpbuf, M_DEVBUF); - b->tmpbuf = malloc(b->bufsize, M_DEVBUF, M_NOWAIT); + + tmpbuf = malloc(b->bufsize, M_DEVBUF, M_NOWAIT); + if (tmpbuf == NULL) + return ENOMEM; + free(b->tmpbuf, M_DEVBUF); + b->tmpbuf = tmpbuf; sndbuf_reset(b); return 0; } @@ -144,7 +148,6 @@ sndbuf_remalloc(struct snd_dbuf *b, unsigned int blkcnt, unsigned int blksz) bufsize = blksz * blkcnt; - buf = malloc(bufsize, M_DEVBUF, M_NOWAIT); if (buf == NULL) return ENOMEM; diff --git a/sys/dev/sound/pcm/feeder_fmt.c b/sys/dev/sound/pcm/feeder_fmt.c index 9306af2..286903f3 100644 --- a/sys/dev/sound/pcm/feeder_fmt.c +++ b/sys/dev/sound/pcm/feeder_fmt.c @@ -210,6 +210,8 @@ static int feed_16to8_init(struct pcm_feeder *f) { f->data = malloc(FEEDBUFSZ, M_FMTFEEDER, M_NOWAIT | M_ZERO); + if (f->data == NULL) + return ENOMEM; return 0; } @@ -319,6 +321,8 @@ static int feed_stereotomono8_init(struct pcm_feeder *f) { f->data = malloc(FEEDBUFSZ, M_FMTFEEDER, M_NOWAIT | M_ZERO); + if (f->data == NULL) + return ENOMEM; return 0; } @@ -364,6 +368,8 @@ static int feed_stereotomono16_init(struct pcm_feeder *f) { f->data = malloc(FEEDBUFSZ, M_FMTFEEDER, M_NOWAIT | M_ZERO); + if (f->data == NULL) + return ENOMEM; return 0; } diff --git a/sys/dev/sound/pcm/feeder_rate.c b/sys/dev/sound/pcm/feeder_rate.c index 540ff97..c3752a0 100644 --- a/sys/dev/sound/pcm/feeder_rate.c +++ b/sys/dev/sound/pcm/feeder_rate.c @@ -250,6 +250,8 @@ feed_rate_init(struct pcm_feeder *f) struct feed_rate_info *info; info = malloc(sizeof(*info), M_RATEFEEDER, M_NOWAIT | M_ZERO); + if (info == NULL) + return ENOMEM; info->src = DSP_DEFAULT_SPEED; info->dst = DSP_DEFAULT_SPEED; info->channels = 2; |