summaryrefslogtreecommitdiff
path: root/sys/miscfs/procfs/procfs_subr.c
diff options
context:
space:
mode:
authorTed Unangst <tedu@cvs.openbsd.org>2003-04-28 02:00:05 +0000
committerTed Unangst <tedu@cvs.openbsd.org>2003-04-28 02:00:05 +0000
commitbabebccc004ac25fdc393da4dd577dac633edb45 (patch)
tree46311c06549ed1b94d4d9f4f0b78762b5457c9ec /sys/miscfs/procfs/procfs_subr.c
parent4e355d546e653c52e870e7af825fe92fd931e61d (diff)
call lockmgr a bit earlier to avoid a race.
Diffstat (limited to 'sys/miscfs/procfs/procfs_subr.c')
-rw-r--r--sys/miscfs/procfs/procfs_subr.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/sys/miscfs/procfs/procfs_subr.c b/sys/miscfs/procfs/procfs_subr.c
index 0ec024a1698..e2bfc25e45a 100644
--- a/sys/miscfs/procfs/procfs_subr.c
+++ b/sys/miscfs/procfs/procfs_subr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: procfs_subr.c,v 1.17 2002/03/14 00:42:25 miod Exp $ */
+/* $OpenBSD: procfs_subr.c,v 1.18 2003/04/28 02:00:04 tedu Exp $ */
/* $NetBSD: procfs_subr.c,v 1.15 1996/02/12 15:01:42 christos Exp $ */
/*
@@ -103,6 +103,12 @@ procfs_allocvp(mp, vpp, pid, pfs_type)
struct vnode *vp;
int error;
+ /*
+ * Lock the vp list, getnewvnode can sleep.
+ */
+ error = lockmgr(&pfs_vlock, LK_EXCLUSIVE, NULL, p);
+ if (error)
+ return (error);
loop:
for (pfs = pfshead.tqh_first; pfs != NULL; pfs = pfs->list.tqe_next) {
vp = PFSTOV(pfs);
@@ -112,15 +118,10 @@ loop:
if (vget(vp, 0, p))
goto loop;
*vpp = vp;
- return (0);
+ goto out;
}
}
- /*
- * Lock the vp list, getnewvnode can sleep.
- */
- lockmgr(&pfs_vlock, LK_EXCLUSIVE, NULL, p);
-
if ((error = getnewvnode(VT_PROCFS, mp, procfs_vnodeop_p, vpp)) != 0)
goto out;
vp = *vpp;