summaryrefslogtreecommitdiffstats
path: root/sys/dev/sge
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2014-06-11 14:53:58 +0000
committerjhb <jhb@FreeBSD.org>2014-06-11 14:53:58 +0000
commite8769d6be243ea7d1540dd79d95893ea33393634 (patch)
tree5544dcfb2be4391a29657081ad30163d6c502e86 /sys/dev/sge
parent60cbac59442236d3d8d9a9d3475a8b1b7421ae33 (diff)
downloadFreeBSD-src-e8769d6be243ea7d1540dd79d95893ea33393634.zip
FreeBSD-src-e8769d6be243ea7d1540dd79d95893ea33393634.tar.gz
Fix various NIC drivers to properly cleanup static DMA resources.
In particular, don't check the value of the bus_dma map against NULL to determine if either bus_dmamem_alloc() or bus_dmamap_load() succeeded. Instead, assume that bus_dmamap_load() succeeeded (and thus that bus_dmamap_unload() should be called) if the bus address for a resource is non-zero, and assume that bus_dmamem_alloc() succeeded (and thus that bus_dmamem_free() should be called) if the virtual address for a resource is not NULL. In many cases these bugs could result in leaks when a driver was detached. Reviewed by: yongari MFC after: 2 weeks
Diffstat (limited to 'sys/dev/sge')
-rw-r--r--sys/dev/sge/if_sge.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/sys/dev/sge/if_sge.c b/sys/dev/sge/if_sge.c
index 20c1428..0774406 100644
--- a/sys/dev/sge/if_sge.c
+++ b/sys/dev/sge/if_sge.c
@@ -916,25 +916,25 @@ sge_dma_free(struct sge_softc *sc)
ld = &sc->sge_ldata;
/* Rx ring. */
if (cd->sge_rx_tag != NULL) {
- if (cd->sge_rx_dmamap != NULL)
+ if (ld->sge_rx_paddr != 0)
bus_dmamap_unload(cd->sge_rx_tag, cd->sge_rx_dmamap);
- if (cd->sge_rx_dmamap != NULL && ld->sge_rx_ring != NULL)
+ if (ld->sge_rx_ring != NULL)
bus_dmamem_free(cd->sge_rx_tag, ld->sge_rx_ring,
cd->sge_rx_dmamap);
ld->sge_rx_ring = NULL;
- cd->sge_rx_dmamap = NULL;
+ ld->sge_rx_paddr = 0;
bus_dma_tag_destroy(cd->sge_rx_tag);
cd->sge_rx_tag = NULL;
}
/* Tx ring. */
if (cd->sge_tx_tag != NULL) {
- if (cd->sge_tx_dmamap != NULL)
+ if (ld->sge_tx_paddr != 0)
bus_dmamap_unload(cd->sge_tx_tag, cd->sge_tx_dmamap);
- if (cd->sge_tx_dmamap != NULL && ld->sge_tx_ring != NULL)
+ if (ld->sge_tx_ring != NULL)
bus_dmamem_free(cd->sge_tx_tag, ld->sge_tx_ring,
cd->sge_tx_dmamap);
ld->sge_tx_ring = NULL;
- cd->sge_tx_dmamap = NULL;
+ ld->sge_tx_paddr = 0;
bus_dma_tag_destroy(cd->sge_tx_tag);
cd->sge_tx_tag = NULL;
}
OpenPOWER on IntegriCloud