Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 17 Sep 2021 13:14:35 GMT
From:      Mark Johnston <markj@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 7959799d93c5 - stable/13 - net: Fix memory leaks upon arp_fillheader() failures
Message-ID:  <202109171314.18HDEZnR088085@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by markj:

URL: https://cgit.FreeBSD.org/src/commit/?id=7959799d93c53a7aa835bb941a478b763efd1649

commit 7959799d93c53a7aa835bb941a478b763efd1649
Author:     orange30 <44566632+orange30@users.noreply.github.com>
AuthorDate: 2021-09-01 15:37:36 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2021-09-17 13:14:12 +0000

    net: Fix memory leaks upon arp_fillheader() failures
    
    Free memory before return from arprequest_internal().  In in_arpinput(),
    if arp_fillheader() fails, it should use goto drop.
    
    Reviewed by:    melifaro, imp, markj
    Pull Request:   https://github.com/freebsd/freebsd-src/pull/534
    
    (cherry picked from commit f5777c123a6382f5fdc9732a87c8fa1ff672f148)
---
 sys/netinet/if_ether.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/sys/netinet/if_ether.c b/sys/netinet/if_ether.c
index 2f92d623feeb..5400f35d953f 100644
--- a/sys/netinet/if_ether.c
+++ b/sys/netinet/if_ether.c
@@ -418,6 +418,7 @@ arprequest_internal(struct ifnet *ifp, const struct in_addr *sip,
 	linkhdrsize = sizeof(linkhdr);
 	error = arp_fillheader(ifp, ah, 1, linkhdr, &linkhdrsize);
 	if (error != 0 && error != EAFNOSUPPORT) {
+		m_freem(m);
 		ARP_LOG(LOG_ERR, "Failed to calculate ARP header on %s: %d\n",
 		    if_name(ifp), error);
 		return (error);
@@ -1128,7 +1129,7 @@ reply:
 	if (error != 0 && error != EAFNOSUPPORT) {
 		ARP_LOG(LOG_ERR, "Failed to calculate ARP header on %s: %d\n",
 		    if_name(ifp), error);
-		return;
+		goto drop;
 	}
 
 	ro.ro_prepend = linkhdr;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202109171314.18HDEZnR088085>