diff --git a/sys/netpfil/pf/pf.c b/sys/netpfil/pf/pf.c --- a/sys/netpfil/pf/pf.c +++ b/sys/netpfil/pf/pf.c @@ -4770,6 +4770,7 @@ struct pf_kstate *s = NULL; struct pf_ksrc_node *sn = NULL; struct tcphdr *th = &pd->hdr.tcp; + struct pf_krule_item *ri; u_int16_t mss = V_tcp_mssdflt; u_short reason, sn_reason; @@ -4994,6 +4995,15 @@ return (PF_PASS); csfailed: + /* + * Free incoming match_rules, not s->match_rules, it might + * have not been copied yet. + */ + while ((ri = SLIST_FIRST(match_rules))) { + SLIST_REMOVE_HEAD(match_rules, entry); + free(ri, M_PF_RULE_ITEM); + } + uma_zfree(V_pf_state_key_z, sk); uma_zfree(V_pf_state_key_z, nk);