summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Pieuchot <mpi@cvs.openbsd.org>2018-04-03 09:07:55 +0000
committerMartin Pieuchot <mpi@cvs.openbsd.org>2018-04-03 09:07:55 +0000
commit12f1f8e74f40d9eabf360eecec44b0f10d49b20a (patch)
tree6ec097bfefb564a1799ec8b51313a90e131f1fd5
parent60c90139b854d49ed3c29b958f462dffe69fa5c4 (diff)
Add proper FREF()/FRELE() dance in sys_fchdir().
The syscall doesn't sleep before a vnode reference is taken, so it doesn't stickly need the refcounts now. But they will be soon be used for parrallelism, so make it ready. ok bluhm@
-rw-r--r--sys/kern/vfs_syscalls.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/sys/kern/vfs_syscalls.c b/sys/kern/vfs_syscalls.c
index 575cb56f0c0..4febb4af085 100644
--- a/sys/kern/vfs_syscalls.c
+++ b/sys/kern/vfs_syscalls.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vfs_syscalls.c,v 1.277 2018/03/28 09:47:52 mpi Exp $ */
+/* $OpenBSD: vfs_syscalls.c,v 1.278 2018/04/03 09:07:54 mpi Exp $ */
/* $NetBSD: vfs_syscalls.c,v 1.71 1996/04/23 10:29:02 mycroft Exp $ */
/*
@@ -745,10 +745,14 @@ sys_fchdir(struct proc *p, void *v, register_t *retval)
if ((fp = fd_getfile(fdp, SCARG(uap, fd))) == NULL)
return (EBADF);
+ FREF(fp);
vp = fp->f_data;
- if (fp->f_type != DTYPE_VNODE || vp->v_type != VDIR)
+ if (fp->f_type != DTYPE_VNODE || vp->v_type != VDIR) {
+ FRELE(fp, p);
return (ENOTDIR);
+ }
vref(vp);
+ FRELE(fp, p);
vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p);
error = VOP_ACCESS(vp, VEXEC, p->p_ucred, p);