diff options
author | adrian <adrian@FreeBSD.org> | 2016-06-23 01:00:13 +0000 |
---|---|---|
committer | adrian <adrian@FreeBSD.org> | 2016-06-23 01:00:13 +0000 |
commit | 0604fa4dc95ed234bfba2645891835ec9a446ec4 (patch) | |
tree | 19fb96208f9f40fa922a81ba185fe17be7240460 /sys/dev/iwm/if_iwm.c | |
parent | 7b9ff22aa0b03de7d79d722bd494ca30c836db61 (diff) | |
download | FreeBSD-src-0604fa4dc95ed234bfba2645891835ec9a446ec4.zip FreeBSD-src-0604fa4dc95ed234bfba2645891835ec9a446ec4.tar.gz |
[iwm] Fix iwm_dma_contig_free(). dma->map is always NULL here.
* When bus_dmamem_alloc is used, the bus_dmamap_t is usually set to NULL, so
we were never actually freeing any dma memory allocations done via
iwm_dma_contig_alloc(). So we should check dma->vaddr instead of dma->map here.
* Also, the dmamap is actually supposed to be invalidated as part of
bus_dmamem_free(), so bus_dmamap_destroy() is never needed here.
Submitted by: Imre Vadasz <imre@vdsz.com>
Approved by: re (gjb)
Obtained from: DragonflyBSD git ef2b29a7ba6ca8a9d2c82ab591c0622227ff84cb
Diffstat (limited to 'sys/dev/iwm/if_iwm.c')
-rw-r--r-- | sys/dev/iwm/if_iwm.c | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/sys/dev/iwm/if_iwm.c b/sys/dev/iwm/if_iwm.c index 4b0f4b8..823de01 100644 --- a/sys/dev/iwm/if_iwm.c +++ b/sys/dev/iwm/if_iwm.c @@ -721,6 +721,7 @@ iwm_dma_contig_alloc(bus_dma_tag_t tag, struct iwm_dma_info *dma, dma->tag = NULL; dma->size = size; + dma->vaddr = NULL; error = bus_dma_tag_create(tag, alignment, 0, BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, size, @@ -735,8 +736,11 @@ iwm_dma_contig_alloc(bus_dma_tag_t tag, struct iwm_dma_info *dma, error = bus_dmamap_load(dma->tag, dma->map, dma->vaddr, size, iwm_dma_map_addr, &dma->paddr, BUS_DMA_NOWAIT); - if (error != 0) + if (error != 0) { + bus_dmamem_free(dma->tag, dma->vaddr, dma->map); + dma->vaddr = NULL; goto fail; + } bus_dmamap_sync(dma->tag, dma->map, BUS_DMASYNC_PREWRITE); @@ -749,16 +753,12 @@ fail: iwm_dma_contig_free(dma); static void iwm_dma_contig_free(struct iwm_dma_info *dma) { - if (dma->map != NULL) { - if (dma->vaddr != NULL) { - bus_dmamap_sync(dma->tag, dma->map, - BUS_DMASYNC_POSTREAD | BUS_DMASYNC_POSTWRITE); - bus_dmamap_unload(dma->tag, dma->map); - bus_dmamem_free(dma->tag, dma->vaddr, dma->map); - dma->vaddr = NULL; - } - bus_dmamap_destroy(dma->tag, dma->map); - dma->map = NULL; + if (dma->vaddr != NULL) { + bus_dmamap_sync(dma->tag, dma->map, + BUS_DMASYNC_POSTREAD | BUS_DMASYNC_POSTWRITE); + bus_dmamap_unload(dma->tag, dma->map); + bus_dmamem_free(dma->tag, dma->vaddr, dma->map); + dma->vaddr = NULL; } if (dma->tag != NULL) { bus_dma_tag_destroy(dma->tag); |