summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_conf.c
diff options
context:
space:
mode:
authorphk <phk@FreeBSD.org>2004-10-01 06:33:39 +0000
committerphk <phk@FreeBSD.org>2004-10-01 06:33:39 +0000
commit2e5b8b98835509cddd3b2345fbdc9d31180a21d9 (patch)
treead89d4adcffc9a9b262d61d0ea417f468fc719ed /sys/kern/kern_conf.c
parentb360d8fe2f7a580cef467da8db8f763a30590de2 (diff)
downloadFreeBSD-src-2e5b8b98835509cddd3b2345fbdc9d31180a21d9.zip
FreeBSD-src-2e5b8b98835509cddd3b2345fbdc9d31180a21d9.tar.gz
Fix a LOR relating to freeing cdevs.
Diffstat (limited to 'sys/kern/kern_conf.c')
-rw-r--r--sys/kern/kern_conf.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/sys/kern/kern_conf.c b/sys/kern/kern_conf.c
index f5d6077..3f7bc44 100644
--- a/sys/kern/kern_conf.c
+++ b/sys/kern/kern_conf.c
@@ -98,17 +98,31 @@ dev_ref(struct cdev *dev)
}
void
-dev_rel(struct cdev *dev)
+dev_rel(struct vnode *vp)
{
+ struct cdev *dev;
+ int flag;
+ dev = vp->v_rdev;
+ mtx_assert(&devmtx, MA_NOTOWNED);
+ dev_lock();
+ SLIST_REMOVE(&dev->si_hlist, vp, vnode, v_specnext);
+ dev->si_usecount -= vp->v_usecount;
+ vp->v_rdev = NULL;
dev->si_refcount--;
KASSERT(dev->si_refcount >= 0,
("dev_rel(%s) gave negative count", devtoname(dev)));
+ flag = 0;
if (dev->si_devsw == NULL && dev->si_refcount == 0) {
LIST_REMOVE(dev, si_list);
- freedev(dev);
+ flag = 1;
}
+ dev_unlock();
+ if (flag)
+ freedev(dev);
+ return;
}
+
struct cdevsw *
dev_refthread(struct cdev *dev)
{
OpenPOWER on IntegriCloud