diff options
author | Martin Pieuchot <mpi@cvs.openbsd.org> | 2018-04-18 09:59:10 +0000 |
---|---|---|
committer | Martin Pieuchot <mpi@cvs.openbsd.org> | 2018-04-18 09:59:10 +0000 |
commit | c9935c3138692fc39e70c8ead7d3eb3c4d7d1746 (patch) | |
tree | 7b1884b8069f5e074bdf5361204d267fa753359e /sys/kern | |
parent | e0321e6fcb6a37209a6773aa2deb00cceb8809a7 (diff) |
Do a FREF()/FRELE() dance after fd_getfile() in sys_fcntl().
ok visa@
Diffstat (limited to 'sys/kern')
-rw-r--r-- | sys/kern/kern_descrip.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c index c6dee90b226..863ee824c19 100644 --- a/sys/kern/kern_descrip.c +++ b/sys/kern/kern_descrip.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_descrip.c,v 1.150 2018/04/12 10:30:18 mpi Exp $ */ +/* $OpenBSD: kern_descrip.c,v 1.151 2018/04/18 09:59:09 mpi Exp $ */ /* $NetBSD: kern_descrip.c,v 1.42 1996/03/30 22:24:38 christos Exp $ */ /* @@ -344,7 +344,7 @@ sys_fcntl(struct proc *p, void *v, register_t *retval) } */ *uap = v; int fd = SCARG(uap, fd); struct filedesc *fdp = p->p_fd; - struct file *fp; + struct file *fp, *fp2; struct vnode *vp; int i, tmp, newmin, flg = F_POSIX; struct flock fl; @@ -530,7 +530,10 @@ restart: goto out; } - if (fp != fd_getfile(fdp, fd)) { + fp2 = fd_getfile(fdp, fd); + if (fp2 != NULL) + FREF(fp2); + if (fp != fp2) { /* * We have lost the race with close() or dup2(); * unlock, pretend that we've won the race and that @@ -542,6 +545,8 @@ restart: VOP_ADVLOCK(vp, fdp, F_UNLCK, &fl, F_POSIX); fl.l_type = F_UNLCK; } + if (fp2 != NULL) + FRELE(fp2, p); goto out; |