git: 81f7ad324dd0 - main - pf: add missing unlock

From: Kristof Provost <kp_at_FreeBSD.org>
Date: Wed, 20 Nov 2024 12:36:21 UTC
The branch main has been updated by kp:

URL: https://cgit.FreeBSD.org/src/commit/?id=81f7ad324dd0cc4f2c090c1504230f4e2d58fb54

commit 81f7ad324dd0cc4f2c090c1504230f4e2d58fb54
Author:     Kristof Provost <kp@FreeBSD.org>
AuthorDate: 2024-11-20 10:45:39 +0000
Commit:     Kristof Provost <kp@FreeBSD.org>
CommitDate: 2024-11-20 12:35:53 +0000

    pf: add missing unlock
    
    If we fail to unshare the mbuf we forgot to unlock the rules.
    
    Sponsored by:   Rubicon Communications, LLC ("Netgate")
---
 sys/netpfil/pf/pf.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/sys/netpfil/pf/pf.c b/sys/netpfil/pf/pf.c
index daf3fcf567ad..39913014334d 100644
--- a/sys/netpfil/pf/pf.c
+++ b/sys/netpfil/pf/pf.c
@@ -9043,8 +9043,10 @@ pf_test(sa_family_t af, int dir, int pflags, struct ifnet *ifp, struct mbuf **m0
 
 	if (__predict_false(! M_WRITABLE(*m0))) {
 		*m0 = m_unshare(*m0, M_NOWAIT);
-		if (*m0 == NULL)
+		if (*m0 == NULL) {
+			PF_RULES_RUNLOCK();
 			return (PF_DROP);
+		}
 	}
 
 	pf_init_pdesc(&pd, *m0);