diff options
author | Orion Hodson <orion@FreeBSD.org> | 2003-04-20 17:08:56 +0000 |
---|---|---|
committer | Orion Hodson <orion@FreeBSD.org> | 2003-04-20 17:08:56 +0000 |
commit | 6635978f234ad6402b92b0f872afe159c65abae9 (patch) | |
tree | ca2af124c6f65c339d3eb396617dd1abc1c3357d /sys/dev | |
parent | b459937e0c1f6af682e795636a45129b451a1962 (diff) | |
download | src-6635978f234ad6402b92b0f872afe159c65abae9.tar.gz src-6635978f234ad6402b92b0f872afe159c65abae9.zip |
Additional malloc failure checks.
Notes
Notes:
svn path=/head/; revision=113752
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 8ae35a37e4d1..30e0996cb5dc 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 9306af2d3285..286903f3bb3c 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 540ff979ede1..c3752a0ad7b1 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; |