summaryrefslogtreecommitdiff
path: root/sys/net
diff options
context:
space:
mode:
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