summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorMartin Pieuchot <mpi@cvs.openbsd.org>2018-04-12 10:30:19 +0000
committerMartin Pieuchot <mpi@cvs.openbsd.org>2018-04-12 10:30:19 +0000
commit6854508a87ff58274cab0ef00e3cc9c3d1a83826 (patch)
tree76be668fffe6ce7059703f56ad4c53494ed2eb3f /sys
parent96f9d9d297a3b3e6ca6782e253d363ceafb336ee (diff)
Use the current reference instead of incrementing `f_count' manually and
calling FRELE(9) in finishdup(). Update comments accordingly. ok bluhm@, visa@
Diffstat (limited to 'sys')
-rw-r--r--sys/kern/kern_descrip.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c
index c223f280388..c6dee90b226 100644
--- a/sys/kern/kern_descrip.c
+++ b/sys/kern/kern_descrip.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_descrip.c,v 1.149 2018/04/12 10:28:13 mpi Exp $ */
+/* $OpenBSD: kern_descrip.c,v 1.150 2018/04/12 10:30:18 mpi Exp $ */
/* $NetBSD: kern_descrip.c,v 1.42 1996/03/30 22:24:38 christos Exp $ */
/*
@@ -241,6 +241,7 @@ restart:
}
goto out;
}
+ /* No need for FRELE(), finishdup() uses current ref. */
error = finishdup(p, fp, old, new, retval, 0);
out:
@@ -320,7 +321,7 @@ restart:
panic("dup2: fdalloc");
fd_unused(fdp, new);
}
- /* finishdup() does FRELE */
+ /* No need for FRELE(), finishdup() uses current ref. */
error = finishdup(p, fp, old, new, retval, 1);
if (!error && flags & O_CLOEXEC)
fdp->fd_ofileflags[new] |= UF_EXCLOSE;
@@ -376,7 +377,7 @@ restart:
goto restart;
}
} else {
- /* finishdup will FRELE for us. */
+ /* No need for FRELE(), finishdup() uses current ref. */
error = finishdup(p, fp, fd, i, retval, 0);
if (!error && SCARG(uap, cmd) == F_DUPFD_CLOEXEC)
@@ -616,8 +617,6 @@ finishdup(struct proc *p, struct file *fp, int old, int new,
fdp->fd_ofiles[new] = fp;
fdp->fd_ofileflags[new] = fdp->fd_ofileflags[old] & ~UF_EXCLOSE;
- fp->f_count++;
- FRELE(fp, p);
if (dup2 && oldfp == NULL)
fd_used(fdp, new);
*retval = new;