diff --git a/sys/kern/sys_pipe.c b/sys/kern/sys_pipe.c index a48c32d0ff93..9d97e3b3ba2f 100644 --- a/sys/kern/sys_pipe.c +++ b/sys/kern/sys_pipe.c @@ -258,10 +258,12 @@ pipe(td, uap) FILEDESC_LOCK(fdp); if (fdp->fd_ofiles[td->td_retval[0]] == rf) { fdp->fd_ofiles[td->td_retval[0]] = NULL; + fdunused(fdp, td->td_retval[0]); FILEDESC_UNLOCK(fdp); fdrop(rf, td); - } else + } else { FILEDESC_UNLOCK(fdp); + } fdrop(rf, td); /* rpipe has been closed by fdrop(). */ pipeclose(wpipe); diff --git a/sys/kern/uipc_syscalls.c b/sys/kern/uipc_syscalls.c index e2ebf33a9a68..b5221f90e94c 100644 --- a/sys/kern/uipc_syscalls.c +++ b/sys/kern/uipc_syscalls.c @@ -125,6 +125,7 @@ socket(td, uap) if (error) { if (fdp->fd_ofiles[fd] == fp) { fdp->fd_ofiles[fd] = NULL; + fdunused(fdp, fd); FILEDESC_UNLOCK(fdp); fdrop(fp, td); } else @@ -390,6 +391,7 @@ accept1(td, uap, compat) FILEDESC_LOCK(fdp); if (fdp->fd_ofiles[fd] == nfp) { fdp->fd_ofiles[fd] = NULL; + fdunused(fdp, fd); FILEDESC_UNLOCK(fdp); fdrop(nfp, td); } else { @@ -584,6 +586,7 @@ socketpair(td, uap) FILEDESC_LOCK(fdp); if (fdp->fd_ofiles[sv[1]] == fp2) { fdp->fd_ofiles[sv[1]] = NULL; + fdunused(fdp, sv[1]); FILEDESC_UNLOCK(fdp); fdrop(fp2, td); } else @@ -593,6 +596,7 @@ socketpair(td, uap) FILEDESC_LOCK(fdp); if (fdp->fd_ofiles[sv[0]] == fp1) { fdp->fd_ofiles[sv[0]] = NULL; + fdunused(fdp, sv[0]); FILEDESC_UNLOCK(fdp); fdrop(fp1, td); } else