diff options
author | Artur Grabowski <art@cvs.openbsd.org> | 2002-11-08 18:38:01 +0000 |
---|---|---|
committer | Artur Grabowski <art@cvs.openbsd.org> | 2002-11-08 18:38:01 +0000 |
commit | e52af0d8c0e7ee5933c8bc30aa02ddd74a97f5c8 (patch) | |
tree | 736df2488b0294e967c94cac42369cb2f0f0661c /sys | |
parent | 0a8189ee1cbb9011fb158d7699785fe1d1b1cb21 (diff) |
finishdup: Avoid reference count leak in error case by reordering some code.
Diffstat (limited to 'sys')
-rw-r--r-- | sys/kern/kern_descrip.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c index aa1208cd02d..21d403e08a1 100644 --- a/sys/kern/kern_descrip.c +++ b/sys/kern/kern_descrip.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_descrip.c,v 1.60 2002/10/15 01:27:31 nordin Exp $ */ +/* $OpenBSD: kern_descrip.c,v 1.61 2002/11/08 18:38:00 art Exp $ */ /* $NetBSD: kern_descrip.c,v 1.42 1996/03/30 22:24:38 christos Exp $ */ /* @@ -504,6 +504,11 @@ finishdup(struct proc *p, struct file *fp, int old, int new, register_t *retval) struct file *oldfp; struct filedesc *fdp = p->p_fd; + if (fp->f_count == LONG_MAX-2) { + FRELE(fp); + return (EDEADLK); + } + /* * Don't fd_getfile here. We want to closef LARVAL files and * closef can deal with that. @@ -512,10 +517,6 @@ finishdup(struct proc *p, struct file *fp, int old, int new, register_t *retval) if (oldfp != NULL) FREF(oldfp); - if (fp->f_count == LONG_MAX-2) { - FRELE(fp); - return (EDEADLK); - } fdp->fd_ofiles[new] = fp; fdp->fd_ofileflags[new] = fdp->fd_ofileflags[old] & ~UF_EXCLOSE; fp->f_count++; |