summaryrefslogtreecommitdiffstats
path: root/sys/arm/at91/if_macb.c
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/arm/at91/if_macb.c
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/arm/at91/if_macb.c')
-rw-r--r--sys/arm/at91/if_macb.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/sys/arm/at91/if_macb.c b/sys/arm/at91/if_macb.c
index 1a46adc..a60cddf 100644
--- a/sys/arm/at91/if_macb.c
+++ b/sys/arm/at91/if_macb.c
@@ -258,14 +258,14 @@ macb_free_desc_dma_tx(struct macb_softc *sc)
/* TX descriptor ring. */
if (sc->dmatag_data_tx != NULL) {
- if (sc->dmamap_ring_tx != NULL)
+ if (sc->ring_paddr_tx != 0)
bus_dmamap_unload(sc->dmatag_data_tx,
sc->dmamap_ring_tx);
- if (sc->dmamap_ring_tx != NULL && sc->desc_tx != NULL)
+ if (sc->desc_tx != NULL)
bus_dmamem_free(sc->dmatag_data_tx, sc->desc_tx,
sc->dmamap_ring_tx);
- sc->dmamap_ring_tx = NULL;
- sc->dmamap_ring_tx = NULL;
+ sc->ring_paddr_tx = 0;
+ sc->desc_tx = NULL;
bus_dma_tag_destroy(sc->dmatag_data_tx);
sc->dmatag_data_tx = NULL;
}
@@ -389,15 +389,14 @@ macb_free_desc_dma_rx(struct macb_softc *sc)
}
/* RX descriptor ring. */
if (sc->dmatag_data_rx != NULL) {
- if (sc->dmamap_ring_rx != NULL)
+ if (sc->ring_paddr_rx != 0)
bus_dmamap_unload(sc->dmatag_data_rx,
sc->dmamap_ring_rx);
- if (sc->dmamap_ring_rx != NULL &&
- sc->desc_rx != NULL)
+ if (sc->desc_rx != NULL)
bus_dmamem_free(sc->dmatag_data_rx, sc->desc_rx,
sc->dmamap_ring_rx);
+ sc->ring_paddr_rx = 0;
sc->desc_rx = NULL;
- sc->dmamap_ring_rx = NULL;
bus_dma_tag_destroy(sc->dmatag_data_rx);
sc->dmatag_data_rx = NULL;
}
OpenPOWER on IntegriCloud