diff options
| author | 1999-05-03 22:30:27 +0000 | |
|---|---|---|
| committer | 1999-05-03 22:30:27 +0000 | |
| commit | eb1e4d36e7d0b62fd6d9414e6ad98dca04f6df61 (patch) | |
| tree | f922b09b550b3b63660726af1f2ba3302156fea7 /sys/net/pfkey.c | |
| parent | sync with gzip 1.2.4a (diff) | |
| download | wireguard-openbsd-eb1e4d36e7d0b62fd6d9414e6ad98dca04f6df61.tar.xz wireguard-openbsd-eb1e4d36e7d0b62fd6d9414e6ad98dca04f6df61.zip | |
Plug mbuf leak
Diffstat (limited to 'sys/net/pfkey.c')
| -rw-r--r-- | sys/net/pfkey.c | 28 |
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 |
