diff options
author | Rafael Zalamena <rzalamena@cvs.openbsd.org> | 2016-11-10 14:10:49 +0000 |
---|---|---|
committer | Rafael Zalamena <rzalamena@cvs.openbsd.org> | 2016-11-10 14:10:49 +0000 |
commit | 6fed93911fd66c46dab1bf44670ae80b39802342 (patch) | |
tree | e824072fd0800f235b6d972420c916ce2487b1d9 /sys/net | |
parent | 6c0d98c799be67b9f5268ea2151ebd85a174c857 (diff) |
Fix swofp_send_error mbuf handling so it doesn't leak mbufs and set the
proper mbuf header length.
ok mikeb@
Diffstat (limited to 'sys/net')
-rw-r--r-- | sys/net/switchofp.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/sys/net/switchofp.c b/sys/net/switchofp.c index c1b071fb90a..2dd37f4b6f2 100644 --- a/sys/net/switchofp.c +++ b/sys/net/switchofp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: switchofp.c,v 1.28 2016/11/07 17:36:09 rzalamena Exp $ */ +/* $OpenBSD: switchofp.c,v 1.29 2016/11/10 14:10:48 rzalamena Exp $ */ /* * Copyright (c) 2016 Kazuya GODA <goda@openbsd.org> @@ -4575,10 +4575,12 @@ swofp_send_error(struct switch_softc *sc, struct mbuf *m, oe->err_type = htons(type); oe->err_code = htons(code); oe->err_oh.oh_length = htons(len + sizeof(struct ofp_error)); - m->m_len = m->m_pkthdr.len = len + sizeof(struct ofp_error); + m->m_len = m->m_pkthdr.len = sizeof(struct ofp_error); - if (m_copyback(m, sizeof(struct ofp_error), len, data, M_DONTWAIT)) + if (m_copyback(m, sizeof(struct ofp_error), len, data, M_DONTWAIT)) { + m_freem(m); return; + } (void)swofp_output(sc, m); } |