diff --git a/sys/dev/bhnd/bhndb/bhndb.c b/sys/dev/bhnd/bhndb/bhndb.c index d2f454ec2906..bbf819131b81 100644 --- a/sys/dev/bhnd/bhndb/bhndb.c +++ b/sys/dev/bhnd/bhndb/bhndb.c @@ -639,6 +639,10 @@ bhndb_generic_detach(device_t dev) if ((error = bus_generic_detach(dev))) return (error); + /* Delete children */ + if ((error = device_delete_children(dev))) + return (error); + /* Clean up our service registry */ if ((error = bhnd_service_registry_fini(&sc->services))) return (error); diff --git a/sys/dev/bhnd/bhndb/bhndb_pci.c b/sys/dev/bhnd/bhndb/bhndb_pci.c index 8ccf77f9e63b..d381f8a01524 100644 --- a/sys/dev/bhnd/bhndb/bhndb_pci.c +++ b/sys/dev/bhnd/bhndb/bhndb_pci.c @@ -303,8 +303,10 @@ bhndb_pci_alloc_msi(struct bhndb_pci_softc *sc, int *msi_count) return (error); } - if (count < BHNDB_PCI_MSI_COUNT) + if (count < BHNDB_PCI_MSI_COUNT) { + pci_release_msi(sc->parent); return (ENXIO); + } *msi_count = count; return (0); @@ -412,7 +414,7 @@ bhndb_pci_attach(device_t dev) bhndb_free_intr_isrc(sc->isrc); if (sc->msi_count > 0) - pci_release_msi(dev); + pci_release_msi(sc->parent); if (cores != NULL) free(cores, M_BHND); @@ -449,7 +451,7 @@ bhndb_pci_detach(device_t dev) /* Release MSI interrupts */ if (sc->msi_count > 0) - pci_release_msi(dev); + pci_release_msi(sc->parent); /* Disable PCI bus mastering */ pci_disable_busmaster(sc->parent);