Fix a few nits relative to the previous changes:

- Don't leak the config lock if detach() fails due to the controller char
  dev being open.
- Close a race between detach() and a process opening the controller char
  dev.

MFC after:	1 week
Approved by:	re (bmah)
This commit is contained in:
John Baldwin 2007-08-13 21:14:16 +00:00
parent 8ec5c98ba4
commit cde586a75c
2 changed files with 9 additions and 2 deletions

View File

@ -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

View File

@ -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;