git: 240a76704b49 - main - if_pfsync: fix mbuf leaks on errors

From: Kristof Provost <kp_at_FreeBSD.org>
Date: Mon, 02 Nov 2026 13:25:08 UTC
The branch main has been updated by kp:

URL: https://cgit.FreeBSD.org/src/commit/?id=240a76704b49b6c67104c5027ddf4d4cf18abfe5

commit 240a76704b49b6c67104c5027ddf4d4cf18abfe5
Author:     Kristof Provost <kp@FreeBSD.org>
AuthorDate: 2026-11-02 10:09:13 +0000
Commit:     Kristof Provost <kp@FreeBSD.org>
CommitDate: 2026-11-02 12:40:01 +0000

    if_pfsync: fix mbuf leaks on errors
    
    Some of the pfsync input handlers freed the mbuf on errors, others did
    not. Unify this by having the caller free the mbuf on error.
    
    Fixes:  c6a520af95b2 (pfsync: improve handling of large packets, 2026-10-30)
    Reported by:    markj's Post-Commit LLM Review Service
    Sponsored by:   Rubicon Communications, LLC ("Netgate")
---
 sys/netpfil/pf/if_pfsync.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/sys/netpfil/pf/if_pfsync.c b/sys/netpfil/pf/if_pfsync.c
index 783d1280d5fb..23916241eb4c 100644
--- a/sys/netpfil/pf/if_pfsync.c
+++ b/sys/netpfil/pf/if_pfsync.c
@@ -1029,6 +1029,7 @@ pfsync_input(struct mbuf **mp, int *offp __unused, int proto __unused)
 		rv = (*pfsync_acts[subh.action])(m, offset, count, flags, subh.action);
 		if (rv == -1) {
 			PF_RULES_RUNLOCK();
+			m_freem(m);
 			return (IPPROTO_DONE);
 		}
 
@@ -1716,7 +1717,6 @@ pfsync_in_eof(struct mbuf *m, int offset, int count, int flags, int action)
 		V_pfsyncstats.pfsyncs_badlen++;
 
 	/* we're done. free and let the caller return */
-	m_freem(m);
 	return (-1);
 }
 
@@ -1725,7 +1725,6 @@ pfsync_in_error(struct mbuf *m, int offset, int count, int flags, int action)
 {
 	V_pfsyncstats.pfsyncs_badact++;
 
-	m_freem(m);
 	return (-1);
 }
 
@@ -1733,7 +1732,6 @@ static int
 pfsyncoutput(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst,
 	struct route *rt)
 {
-	m_freem(m);
 	return (0);
 }