diff options
author | 2018-03-28 09:49:28 +0000 | |
---|---|---|
committer | 2018-03-28 09:49:28 +0000 | |
commit | e13ac0275649309058c75bd90433bcaa0b3d5f0c (patch) | |
tree | f758a679e722a9ff2c222930863c19c9590324fe /sys | |
parent | Call FREF() right after fd_getfile*() in pread(), prwrite() & co. (diff) | |
download | wireguard-openbsd-e13ac0275649309058c75bd90433bcaa0b3d5f0c.tar.xz wireguard-openbsd-e13ac0275649309058c75bd90433bcaa0b3d5f0c.zip |
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')
-rw-r--r-- | sys/kern/kern_descrip.c | 8 |
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; |