if_ovpn: fix mbuf leak

If the link is down or we can't find a peer we do not transmit the
packet, but also don't fee it.

Remember to m_freem() mbufs we can't transmit.

Sponsored by:	Rubicon Communications, LLC ("Netgate")
This commit is contained in:
Kristof Provost 2022-07-12 14:19:25 +02:00
parent 7e06f4708c
commit 59219dde9a

View File

@ -1988,6 +1988,7 @@ ovpn_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst,
if (__predict_false(ifp->if_link_state != LINK_STATE_UP)) {
OVPN_COUNTER_ADD(sc, lost_data_pkts_out, 1);
OVPN_RUNLOCK(sc);
m_freem(m);
return (ENETDOWN);
}
@ -2005,6 +2006,7 @@ ovpn_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst,
/* No destination. */
OVPN_COUNTER_ADD(sc, lost_data_pkts_out, 1);
OVPN_RUNLOCK(sc);
m_freem(m);
return (ENETDOWN);
}