Use device_delete_children instead of explicit calls to device_delete_child
This is simpler and more robust in the face of potential double-frees (e.g. if called after bus_generic_detach which will delete devices in a future commit). Reviewed by: manu, imp Differential Revision: https://reviews.freebsd.org/D47958
This commit is contained in:
@@ -482,7 +482,6 @@ static int
|
||||
aw_mmc_detach(device_t dev)
|
||||
{
|
||||
struct aw_mmc_softc *sc;
|
||||
device_t d;
|
||||
|
||||
sc = device_get_softc(dev);
|
||||
|
||||
@@ -494,12 +493,7 @@ aw_mmc_detach(device_t dev)
|
||||
|
||||
callout_drain(&sc->aw_timeoutc);
|
||||
|
||||
AW_MMC_LOCK(sc);
|
||||
d = sc->child;
|
||||
sc->child = NULL;
|
||||
AW_MMC_UNLOCK(sc);
|
||||
if (d != NULL)
|
||||
device_delete_child(sc->aw_dev, d);
|
||||
device_delete_children(sc->aw_dev);
|
||||
|
||||
aw_mmc_teardown_dma(sc);
|
||||
|
||||
|
||||
@@ -365,10 +365,7 @@ static void
|
||||
gen_destroy(struct gen_softc *sc)
|
||||
{
|
||||
|
||||
if (sc->miibus) { /* can't happen */
|
||||
device_delete_child(sc->dev, sc->miibus);
|
||||
sc->miibus = NULL;
|
||||
}
|
||||
device_delete_children(sc->dev);
|
||||
bus_teardown_intr(sc->dev, sc->res[_RES_IRQ1], sc->ih);
|
||||
bus_teardown_intr(sc->dev, sc->res[_RES_IRQ2], sc->ih2);
|
||||
gen_bus_dma_teardown(sc);
|
||||
|
||||
@@ -202,8 +202,7 @@ intsmb_release_resources(device_t dev)
|
||||
{
|
||||
struct intsmb_softc *sc = device_get_softc(dev);
|
||||
|
||||
if (sc->smbus)
|
||||
device_delete_child(dev, sc->smbus);
|
||||
device_delete_children(dev);
|
||||
if (sc->irq_hand)
|
||||
bus_teardown_intr(dev, sc->irq_res, sc->irq_hand);
|
||||
if (sc->irq_res)
|
||||
|
||||
Reference in New Issue
Block a user