git: 0044bd90f239 - main - pf: fix memory leak retrieving Ethernet rules

From: Kristof Provost <kp_at_FreeBSD.org>
Date: Tue, 27 Sep 2022 13:28:47 UTC
The branch main has been updated by kp:

URL: https://cgit.FreeBSD.org/src/commit/?id=0044bd90f2397dfad5f4bbd12c64be86e0b7eb4a

commit 0044bd90f2397dfad5f4bbd12c64be86e0b7eb4a
Author:     Kristof Provost <kp@FreeBSD.org>
AuthorDate: 2022-09-27 13:27:47 +0000
Commit:     Kristof Provost <kp@FreeBSD.org>
CommitDate: 2022-09-27 13:28:37 +0000

    pf: fix memory leak retrieving Ethernet rules
    
    Remember to free the nvlist we've added to our main nvlist.
    
    Sponsored by:   Rubicon Communications, LLC ("Netgate")
---
 sys/netpfil/pf/pf_nv.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/sys/netpfil/pf/pf_nv.c b/sys/netpfil/pf/pf_nv.c
index 456433ccbf70..18495c118e75 100644
--- a/sys/netpfil/pf/pf_nv.c
+++ b/sys/netpfil/pf/pf_nv.c
@@ -1067,6 +1067,7 @@ pf_keth_rule_to_nveth_rule(const struct pf_keth_rule *krule)
 		return (NULL);
 	}
 	nvlist_add_nvlist(nvl, "src", addr);
+	nvlist_destroy(addr);
 
 	addr = pf_keth_rule_addr_to_nveth_rule_addr(&krule->dst);
 	if (addr == NULL) {
@@ -1074,6 +1075,7 @@ pf_keth_rule_to_nveth_rule(const struct pf_keth_rule *krule)
 		return (NULL);
 	}
 	nvlist_add_nvlist(nvl, "dst", addr);
+	nvlist_destroy(addr);
 
 	addr = pf_rule_addr_to_nvrule_addr(&krule->ipsrc);
 	if (addr == NULL) {