diff options
author | cognet <cognet@FreeBSD.org> | 2012-12-22 01:04:29 +0000 |
---|---|---|
committer | cognet <cognet@FreeBSD.org> | 2012-12-22 01:04:29 +0000 |
commit | 25bbadc6fac9a2e1d210ffab515cdb99cb43d38c (patch) | |
tree | 27f3258ac85e2bbb3539ae212565f318ad45bf20 /sys/arm | |
parent | c4f3118502f9e2d3aeadc397e81b774126da4a63 (diff) | |
download | FreeBSD-src-25bbadc6fac9a2e1d210ffab515cdb99cb43d38c.zip FreeBSD-src-25bbadc6fac9a2e1d210ffab515cdb99cb43d38c.tar.gz |
The manpage states that bus_dmamap_create(9) returns ENOMEM if it can't
allocate a map or mapping resources. That seems to imply that any memory
allocations it does must use M_NOWAIT and check for NULL.
Submitted by: Ian Lepore <freebsd@damnhippie.dyndns.org>
Diffstat (limited to 'sys/arm')
-rw-r--r-- | sys/arm/arm/busdma_machdep.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/sys/arm/arm/busdma_machdep.c b/sys/arm/arm/busdma_machdep.c index c5eb02d3..42566e8 100644 --- a/sys/arm/arm/busdma_machdep.c +++ b/sys/arm/arm/busdma_machdep.c @@ -567,16 +567,24 @@ bus_dmamap_create(bus_dma_tag_t dmat, int flags, bus_dmamap_t *mapp) bus_dmamap_t map; int error = 0; - map = uma_zalloc_arg(dmamap_zone, dmat, M_WAITOK); + map = uma_zalloc_arg(dmamap_zone, dmat, M_NOWAIT); *mapp = map; + if (map == NULL) + return (ENOMEM); /* * If the tag's segments haven't been allocated yet we need to do it * now, because we can't sleep for resources at map load time. */ - if (dmat->segments == NULL) + if (dmat->segments == NULL) { dmat->segments = malloc(dmat->nsegments * - sizeof(*dmat->segments), M_DEVBUF, M_WAITOK); + sizeof(*dmat->segments), M_DEVBUF, M_NOWAIT); + if (dmat->segments == NULL) { + uma_zfree(dmamap_zone, map); + *mapp = NULL; + return (ENOMEM); + } + } /* * Bouncing might be required if the driver asks for an active |