summaryrefslogtreecommitdiffstats
path: root/sys/dev/sis
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/sis
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/sis')
-rw-r--r--sys/dev/sis/if_sis.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/sys/dev/sis/if_sis.c b/sys/dev/sis/if_sis.c
index 632b384..09e2242 100644
--- a/sys/dev/sis/if_sis.c
+++ b/sys/dev/sis/if_sis.c
@@ -1329,9 +1329,9 @@ sis_dma_free(struct sis_softc *sc)
bus_dma_tag_destroy(sc->sis_tx_tag);
/* Destroy RX ring. */
- if (sc->sis_rx_list_map)
+ if (sc->sis_rx_paddr)
bus_dmamap_unload(sc->sis_rx_list_tag, sc->sis_rx_list_map);
- if (sc->sis_rx_list_map && sc->sis_rx_list)
+ if (sc->sis_rx_list)
bus_dmamem_free(sc->sis_rx_list_tag, sc->sis_rx_list,
sc->sis_rx_list_map);
@@ -1339,10 +1339,10 @@ sis_dma_free(struct sis_softc *sc)
bus_dma_tag_destroy(sc->sis_rx_list_tag);
/* Destroy TX ring. */
- if (sc->sis_tx_list_map)
+ if (sc->sis_tx_paddr)
bus_dmamap_unload(sc->sis_tx_list_tag, sc->sis_tx_list_map);
- if (sc->sis_tx_list_map && sc->sis_tx_list)
+ if (sc->sis_tx_list)
bus_dmamem_free(sc->sis_tx_list_tag, sc->sis_tx_list,
sc->sis_tx_list_map);
OpenPOWER on IntegriCloud