diff options
author | John Baldwin <jhb@FreeBSD.org> | 2014-06-11 14:53:58 +0000 |
---|---|---|
committer | John Baldwin <jhb@FreeBSD.org> | 2014-06-11 14:53:58 +0000 |
commit | 068d8643adb13434b57fdd5febf43a11194d508f (patch) | |
tree | 5544dcfb2be4391a29657081ad30163d6c502e86 /sys/dev/ste | |
parent | 4f655310bff3d8052e35426ad6188a81147a7ed9 (diff) | |
download | src-068d8643adb13434b57fdd5febf43a11194d508f.tar.gz src-068d8643adb13434b57fdd5febf43a11194d508f.zip |
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
Notes
Notes:
svn path=/head/; revision=267363
Diffstat (limited to 'sys/dev/ste')
-rw-r--r-- | sys/dev/ste/if_ste.c | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/sys/dev/ste/if_ste.c b/sys/dev/ste/if_ste.c index 107d77a24cdb..ae574aa699ef 100644 --- a/sys/dev/ste/if_ste.c +++ b/sys/dev/ste/if_ste.c @@ -1344,31 +1344,29 @@ ste_dma_free(struct ste_softc *sc) } /* Tx descriptor list. */ if (sc->ste_cdata.ste_tx_list_tag != NULL) { - if (sc->ste_cdata.ste_tx_list_map != NULL) + if (sc->ste_ldata.ste_tx_list_paddr != 0) bus_dmamap_unload(sc->ste_cdata.ste_tx_list_tag, sc->ste_cdata.ste_tx_list_map); - if (sc->ste_cdata.ste_tx_list_map != NULL && - sc->ste_ldata.ste_tx_list != NULL) + if (sc->ste_ldata.ste_tx_list != NULL) bus_dmamem_free(sc->ste_cdata.ste_tx_list_tag, sc->ste_ldata.ste_tx_list, sc->ste_cdata.ste_tx_list_map); sc->ste_ldata.ste_tx_list = NULL; - sc->ste_cdata.ste_tx_list_map = NULL; + sc->ste_ldata.ste_tx_list_paddr = 0; bus_dma_tag_destroy(sc->ste_cdata.ste_tx_list_tag); sc->ste_cdata.ste_tx_list_tag = NULL; } /* Rx descriptor list. */ if (sc->ste_cdata.ste_rx_list_tag != NULL) { - if (sc->ste_cdata.ste_rx_list_map != NULL) + if (sc->ste_ldata.ste_rx_list_paddr != 0) bus_dmamap_unload(sc->ste_cdata.ste_rx_list_tag, sc->ste_cdata.ste_rx_list_map); - if (sc->ste_cdata.ste_rx_list_map != NULL && - sc->ste_ldata.ste_rx_list != NULL) + if (sc->ste_ldata.ste_rx_list != NULL) bus_dmamem_free(sc->ste_cdata.ste_rx_list_tag, sc->ste_ldata.ste_rx_list, sc->ste_cdata.ste_rx_list_map); sc->ste_ldata.ste_rx_list = NULL; - sc->ste_cdata.ste_rx_list_map = NULL; + sc->ste_ldata.ste_rx_list_paddr = 0; bus_dma_tag_destroy(sc->ste_cdata.ste_rx_list_tag); sc->ste_cdata.ste_rx_list_tag = NULL; } |