diff --git a/sys/dev/mfi/mfi.c b/sys/dev/mfi/mfi.c index b5b2eb9d5a83..3a96d9642823 100644 --- a/sys/dev/mfi/mfi.c +++ b/sys/dev/mfi/mfi.c @@ -1779,14 +1779,20 @@ static int mfi_open(struct cdev *dev, int flags, int fmt, d_thread_t *td) { struct mfi_softc *sc; + int error; sc = dev->si_drv1; mtx_lock(&sc->mfi_io_lock); - sc->mfi_flags |= MFI_FLAGS_OPEN; + if (sc->mfi_detaching) + error = ENXIO; + else { + sc->mfi_flags |= MFI_FLAGS_OPEN; + error = 0; + } mtx_unlock(&sc->mfi_io_lock); - return (0); + return (error); } static int diff --git a/sys/dev/mfi/mfi_pci.c b/sys/dev/mfi/mfi_pci.c index a335bd21eef0..45e831140180 100644 --- a/sys/dev/mfi/mfi_pci.c +++ b/sys/dev/mfi/mfi_pci.c @@ -204,6 +204,7 @@ mfi_pci_detach(device_t dev) mtx_lock(&sc->mfi_io_lock); if ((sc->mfi_flags & MFI_FLAGS_OPEN) != 0) { mtx_unlock(&sc->mfi_io_lock); + sx_xunlock(&sc->mfi_config_lock); return (EBUSY); } sc->mfi_detaching = 1;