diff options
author | 2018-04-12 10:30:18 +0000 | |
---|---|---|
committer | 2018-04-12 10:30:18 +0000 | |
commit | 489997fe3f18b1a6021653516b2b42b8295c32c3 (patch) | |
tree | f288395164656d4062e62f240d93ef71dcce4e09 | |
parent | Call FREF(9) earlier instead of incrementing `f_count' directly in (diff) | |
download | wireguard-openbsd-489997fe3f18b1a6021653516b2b42b8295c32c3.tar.xz wireguard-openbsd-489997fe3f18b1a6021653516b2b42b8295c32c3.zip |
Use the current reference instead of incrementing `f_count' manually and
calling FRELE(9) in finishdup().
Update comments accordingly.
ok bluhm@, visa@
-rw-r--r-- | sys/kern/kern_descrip.c | 9 |
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; |