diff options
author | jhb <jhb@FreeBSD.org> | 2007-08-13 21:14:16 +0000 |
---|---|---|
committer | jhb <jhb@FreeBSD.org> | 2007-08-13 21:14:16 +0000 |
commit | 729445db78b576febeacaffe13ab750da580c2b8 (patch) | |
tree | 55547c26582b25fecc51d2d0d7dfedd403991224 /sys | |
parent | da9c015b527e4b42873e708244f9c5d05aa9631d (diff) | |
download | FreeBSD-src-729445db78b576febeacaffe13ab750da580c2b8.zip FreeBSD-src-729445db78b576febeacaffe13ab750da580c2b8.tar.gz |
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)
Diffstat (limited to 'sys')
-rw-r--r-- | sys/dev/mfi/mfi.c | 10 | ||||
-rw-r--r-- | sys/dev/mfi/mfi_pci.c | 1 |
2 files changed, 9 insertions, 2 deletions
diff --git a/sys/dev/mfi/mfi.c b/sys/dev/mfi/mfi.c index b5b2eb9..3a96d96 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 a335bd2..45e8311 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; |