summaryrefslogtreecommitdiff
path: root/sys/kern
diff options
context:
space:
mode:
authorMartin Pieuchot <mpi@cvs.openbsd.org>2018-03-28 09:49:29 +0000
committerMartin Pieuchot <mpi@cvs.openbsd.org>2018-03-28 09:49:29 +0000
commite62b95c9608ded01c745035bef50173851a27cab (patch)
tree290977d7037b2fea79b18eb649332695c2991364 /sys/kern
parentc2c9c7d5c3ca3d9adfaa17702d7f3d7a8fce71c7 (diff)
Call FREF() right after fd_getfile() in sys_flock().
This ensure that all operations manipulating a 'struct file *' do so with a properly refcounted element. ok visa@, bluhm@
Diffstat (limited to 'sys/kern')
-rw-r--r--sys/kern/kern_descrip.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c
index 10b04d6736e..dfd92c9f09d 100644
--- a/sys/kern/kern_descrip.c
+++ b/sys/kern/kern_descrip.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_descrip.c,v 1.142 2018/02/19 08:59:52 mpi Exp $ */
+/* $OpenBSD: kern_descrip.c,v 1.143 2018/03/28 09:49:28 mpi Exp $ */
/* $NetBSD: kern_descrip.c,v 1.42 1996/03/30 22:24:38 christos Exp $ */
/*
@@ -1205,9 +1205,11 @@ sys_flock(struct proc *p, void *v, register_t *retval)
if ((fp = fd_getfile(fdp, fd)) == NULL)
return (EBADF);
- if (fp->f_type != DTYPE_VNODE)
- return (EOPNOTSUPP);
FREF(fp);
+ if (fp->f_type != DTYPE_VNODE) {
+ error = EOPNOTSUPP;
+ goto out;
+ }
vp = fp->f_data;
lf.l_whence = SEEK_SET;
lf.l_start = 0;