summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Pieuchot <mpi@cvs.openbsd.org>2018-05-22 09:51:02 +0000
committerMartin Pieuchot <mpi@cvs.openbsd.org>2018-05-22 09:51:02 +0000
commit7b4ec3de287166e0e7e2d4009cde7f44ccf8436b (patch)
tree3e57e75511368d0bd299e0da3b49e433c5e617c7
parentdbc00665addacfb4fe58f83ac39d31508389b024 (diff)
Prevent NET_LOCK() recursion when releasing the last `fp' reference.
ok bluhm@, visa@
-rw-r--r--sys/kern/uipc_syscalls.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/sys/kern/uipc_syscalls.c b/sys/kern/uipc_syscalls.c
index 483f803a0df..c91dc5264de 100644
--- a/sys/kern/uipc_syscalls.c
+++ b/sys/kern/uipc_syscalls.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uipc_syscalls.c,v 1.170 2018/05/08 08:53:41 mpi Exp $ */
+/* $OpenBSD: uipc_syscalls.c,v 1.171 2018/05/22 09:51:01 mpi Exp $ */
/* $NetBSD: uipc_syscalls.c,v 1.19 1996/02/09 19:00:48 christos Exp $ */
/*
@@ -340,24 +340,25 @@ doaccept(struct proc *p, int sock, struct sockaddr *name, socklen_t *anamelen,
error = soaccept(so, nam);
if (!error && name != NULL)
error = copyaddrout(p, nam, name, namelen, anamelen);
+out:
if (!error) {
if (nflag & FNONBLOCK)
so->so_state |= SS_NBIO;
else
so->so_state &= ~SS_NBIO;
+ sounlock(s);
fp->f_data = so;
FILE_SET_MATURE(fp, p);
*retval = tmpfd;
- }
-out:
- sounlock(s);
- m_freem(nam);
- if (error) {
+ } else {
+ sounlock(s);
fdplock(fdp);
fdremove(fdp, tmpfd);
closef(fp, p);
fdpunlock(fdp);
}
+
+ m_freem(nam);
FRELE(headfp, p);
return (error);
}