summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Pieuchot <mpi@cvs.openbsd.org>2018-04-03 09:00:04 +0000
committerMartin Pieuchot <mpi@cvs.openbsd.org>2018-04-03 09:00:04 +0000
commit60c90139b854d49ed3c29b958f462dffe69fa5c4 (patch)
tree079dd62e981e87b4be5758bb9eaf75a54611f444
parentbe96f2ecec68c3ad901d3afec161d6129ecd081f (diff)
Call FREF() right after fd_getfile() in dodup3().
ok millert@, bluhm@
-rw-r--r--sys/kern/kern_descrip.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c
index dfd92c9f09d..dde0442521a 100644
--- a/sys/kern/kern_descrip.c
+++ b/sys/kern/kern_descrip.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_descrip.c,v 1.143 2018/03/28 09:49:28 mpi Exp $ */
+/* $OpenBSD: kern_descrip.c,v 1.144 2018/04/03 09:00:03 mpi Exp $ */
/* $NetBSD: kern_descrip.c,v 1.42 1996/03/30 22:24:38 christos Exp $ */
/*
@@ -289,9 +289,12 @@ dodup3(struct proc *p, int old, int new, int flags, register_t *retval)
restart:
if ((fp = fd_getfile(fdp, old)) == NULL)
return (EBADF);
+ FREF(fp);
if ((u_int)new >= p->p_rlimit[RLIMIT_NOFILE].rlim_cur ||
- (u_int)new >= maxfiles)
+ (u_int)new >= maxfiles) {
+ FRELE(fp, p);
return (EBADF);
+ }
if (old == new) {
/*
* NOTE! This doesn't clear the close-on-exec flag. This might
@@ -299,9 +302,9 @@ restart:
* this is what everyone else does.
*/
*retval = new;
+ FRELE(fp, p);
return (0);
}
- FREF(fp);
fdplock(fdp);
if (new >= fdp->fd_nfiles) {
if ((error = fdalloc(p, new, &i)) != 0) {