When bus_alloc_resource_any() fails, dc_detach() is called and it
attempts to deallocate busdma tags and resources that haven't been allocated yet, causing a panic every time a dc interface fails to attach. Fix by checking that we really have something to dealloc before calling bus_dma*() functions. Approved by: jhb MFC after: 1 week
This commit is contained in:
parent
f726a87319
commit
4f867c2d17
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=150174
@ -2364,11 +2364,17 @@ dc_detach(device_t dev)
|
||||
bus_dmamem_free(sc->dc_stag, sc->dc_cdata.dc_sbuf, sc->dc_smap);
|
||||
if (sc->dc_ldata != NULL)
|
||||
bus_dmamem_free(sc->dc_ltag, sc->dc_ldata, sc->dc_lmap);
|
||||
for (i = 0; i < DC_TX_LIST_CNT; i++)
|
||||
bus_dmamap_destroy(sc->dc_mtag, sc->dc_cdata.dc_tx_map[i]);
|
||||
for (i = 0; i < DC_RX_LIST_CNT; i++)
|
||||
bus_dmamap_destroy(sc->dc_mtag, sc->dc_cdata.dc_rx_map[i]);
|
||||
bus_dmamap_destroy(sc->dc_mtag, sc->dc_sparemap);
|
||||
if (sc->dc_mtag) {
|
||||
for (i = 0; i < DC_TX_LIST_CNT; i++)
|
||||
if (sc->dc_cdata.dc_tx_map[i] != NULL)
|
||||
bus_dmamap_destroy(sc->dc_mtag,
|
||||
sc->dc_cdata.dc_tx_map[i]);
|
||||
for (i = 0; i < DC_RX_LIST_CNT; i++)
|
||||
if (sc->dc_cdata.dc_rx_map[i] != NULL)
|
||||
bus_dmamap_destroy(sc->dc_mtag,
|
||||
sc->dc_cdata.dc_rx_map[i]);
|
||||
bus_dmamap_destroy(sc->dc_mtag, sc->dc_sparemap);
|
||||
}
|
||||
if (sc->dc_stag)
|
||||
bus_dma_tag_destroy(sc->dc_stag);
|
||||
if (sc->dc_mtag)
|
||||
|
@ -2364,11 +2364,17 @@ dc_detach(device_t dev)
|
||||
bus_dmamem_free(sc->dc_stag, sc->dc_cdata.dc_sbuf, sc->dc_smap);
|
||||
if (sc->dc_ldata != NULL)
|
||||
bus_dmamem_free(sc->dc_ltag, sc->dc_ldata, sc->dc_lmap);
|
||||
for (i = 0; i < DC_TX_LIST_CNT; i++)
|
||||
bus_dmamap_destroy(sc->dc_mtag, sc->dc_cdata.dc_tx_map[i]);
|
||||
for (i = 0; i < DC_RX_LIST_CNT; i++)
|
||||
bus_dmamap_destroy(sc->dc_mtag, sc->dc_cdata.dc_rx_map[i]);
|
||||
bus_dmamap_destroy(sc->dc_mtag, sc->dc_sparemap);
|
||||
if (sc->dc_mtag) {
|
||||
for (i = 0; i < DC_TX_LIST_CNT; i++)
|
||||
if (sc->dc_cdata.dc_tx_map[i] != NULL)
|
||||
bus_dmamap_destroy(sc->dc_mtag,
|
||||
sc->dc_cdata.dc_tx_map[i]);
|
||||
for (i = 0; i < DC_RX_LIST_CNT; i++)
|
||||
if (sc->dc_cdata.dc_rx_map[i] != NULL)
|
||||
bus_dmamap_destroy(sc->dc_mtag,
|
||||
sc->dc_cdata.dc_rx_map[i]);
|
||||
bus_dmamap_destroy(sc->dc_mtag, sc->dc_sparemap);
|
||||
}
|
||||
if (sc->dc_stag)
|
||||
bus_dma_tag_destroy(sc->dc_stag);
|
||||
if (sc->dc_mtag)
|
||||
|
Loading…
Reference in New Issue
Block a user