summaryrefslogtreecommitdiffstats
path: root/sys/netinet/udp_usrreq.c
diff options
context:
space:
mode:
authorbluhm <bluhm@openbsd.org>2013-03-31 11:18:35 +0000
committerbluhm <bluhm@openbsd.org>2013-03-31 11:18:35 +0000
commitae39fdefb07f899fb0eca4b9a5449774dc9da4f8 (patch)
treeeada1234f7c138eee3724394df14e9c639c0aab0 /sys/netinet/udp_usrreq.c
parentProvide default resource allocation and free functions. Convert all (diff)
downloadwireguard-openbsd-ae39fdefb07f899fb0eca4b9a5449774dc9da4f8.tar.xz
wireguard-openbsd-ae39fdefb07f899fb0eca4b9a5449774dc9da4f8.zip
The call to in_pcballoc() in user request attach was handled in
three different ways. Use the same code in udp_usrreq() and rip_usrreq() and rip6_usrreq(). This also fixes a pcb and socket leak in udp_usrreq() in case soreserve() fails. Put an splsoftassert() into in_pcballoc() for safety. OK mpi@
Diffstat (limited to 'sys/netinet/udp_usrreq.c')
-rw-r--r--sys/netinet/udp_usrreq.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/sys/netinet/udp_usrreq.c b/sys/netinet/udp_usrreq.c
index a289e93ac29..f5c1c094c94 100644
--- a/sys/netinet/udp_usrreq.c
+++ b/sys/netinet/udp_usrreq.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: udp_usrreq.c,v 1.156 2013/03/31 00:59:52 bluhm Exp $ */
+/* $OpenBSD: udp_usrreq.c,v 1.157 2013/03/31 11:18:35 bluhm Exp $ */
/* $NetBSD: udp_usrreq.c,v 1.28 1996/03/16 23:54:03 christos Exp $ */
/*
@@ -1153,13 +1153,12 @@ udp_usrreq(struct socket *so, int req, struct mbuf *m, struct mbuf *addr,
break;
}
s = splsoftnet();
- error = in_pcballoc(so, &udbtable);
- splx(s);
- if (error)
- break;
- error = soreserve(so, udp_sendspace, udp_recvspace);
- if (error)
+ if ((error = soreserve(so, udp_sendspace, udp_recvspace)) ||
+ (error = in_pcballoc(so, &udbtable))) {
+ splx(s);
break;
+ }
+ splx(s);
#ifdef INET6
if (((struct inpcb *)so->so_pcb)->inp_flags & INP_IPV6)
((struct inpcb *) so->so_pcb)->inp_ipv6.ip6_hlim =