diff options
author | 2018-04-03 09:00:03 +0000 | |
---|---|---|
committer | 2018-04-03 09:00:03 +0000 | |
commit | f0b68073ced50c5afcf4124d4f34a5cf55f1ca83 (patch) | |
tree | 0b62a9c4cdfa008e6e776b42192a11343af10073 | |
parent | Silence assertwaitok() if we are in ddb(4). (diff) | |
download | wireguard-openbsd-f0b68073ced50c5afcf4124d4f34a5cf55f1ca83.tar.xz wireguard-openbsd-f0b68073ced50c5afcf4124d4f34a5cf55f1ca83.zip |
Call FREF() right after fd_getfile() in dodup3().
ok millert@, bluhm@
-rw-r--r-- | sys/kern/kern_descrip.c | 9 |
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) { |