summaryrefslogtreecommitdiff
path: root/sys/net
diff options
context:
space:
mode:
authorNiklas Hallqvist <niklas@cvs.openbsd.org>1999-05-03 22:30:28 +0000
committerNiklas Hallqvist <niklas@cvs.openbsd.org>1999-05-03 22:30:28 +0000
commit79cba73d6ef7deefbea7bc76bded3380f4482a5a (patch)
treec022ab0b505b09aeac744c758e8190984206463b /sys/net
parent31a4863cdab6e9c8a67aee811ece5b0ea953b0e8 (diff)
Plug mbuf leak
Diffstat (limited to 'sys/net')
-rw-r--r--sys/net/pfkey.c28
1 files changed, 21 insertions, 7 deletions
diff --git a/sys/net/pfkey.c b/sys/net/pfkey.c
index 27935830e21..42be9bd022b 100644
--- a/sys/net/pfkey.c
+++ b/sys/net/pfkey.c
@@ -117,22 +117,36 @@ static int
pfkey_output(struct mbuf *mbuf, struct socket *socket)
{
void *message;
+ int error = 0;
#if DIAGNOSTIC
- if (!mbuf || !(mbuf->m_flags & M_PKTHDR))
- return EINVAL;
+ if (!mbuf || !(mbuf->m_flags & M_PKTHDR)) {
+ error = EINVAL;
+ goto ret;
+ }
#endif /* DIAGNOSTIC */
- if (mbuf->m_pkthdr.len > PFKEY_MSG_MAXSZ)
- return EMSGSIZE;
+ if (mbuf->m_pkthdr.len > PFKEY_MSG_MAXSZ) {
+ error = EMSGSIZE;
+ goto ret;
+ }
if (!(message = malloc((unsigned long) mbuf->m_pkthdr.len, M_TEMP,
- M_DONTWAIT)))
- return ENOMEM;
+ M_DONTWAIT))) {
+ error = ENOMEM;
+ goto ret;
+ }
m_copydata(mbuf, 0, mbuf->m_pkthdr.len, message);
- return pfkey_versions[socket->so_proto->pr_protocol]->send(socket, message, mbuf->m_pkthdr.len);
+ error =
+ pfkey_versions[socket->so_proto->pr_protocol]->send(socket, message,
+ mbuf->m_pkthdr.len);
+
+ ret:
+ if (mbuf)
+ m_freem (mbuf);
+ return error;
}
static int