git: af5313249730 - main - pf: don't leak transaction elements on error
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 02 Nov 2026 13:25:04 UTC
The branch main has been updated by kp:
URL: https://cgit.FreeBSD.org/src/commit/?id=af531324973021c5dc2cec47d0ef346666a4a551
commit af531324973021c5dc2cec47d0ef346666a4a551
Author: Kristof Provost <kp@FreeBSD.org>
AuthorDate: 2026-11-02 09:42:04 +0000
Commit: Kristof Provost <kp@FreeBSD.org>
CommitDate: 2026-11-02 12:40:01 +0000
pf: don't leak transaction elements on error
If nlmsg_reply() or nlmsg_end() in pf_handle_trans() failed we did not
call pf_trans_free(), leaking the pf_trans_e elements in it.
Reported by: markj's Post-Commit LLM Review Service
Sponsored by: Rubicon Communications, LLC ("Netgate")
---
sys/netpfil/pf/pf_nl.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/sys/netpfil/pf/pf_nl.c b/sys/netpfil/pf/pf_nl.c
index ba9191745966..56b4d55fe0d4 100644
--- a/sys/netpfil/pf/pf_nl.c
+++ b/sys/netpfil/pf/pf_nl.c
@@ -3150,8 +3150,10 @@ pf_handle_trans(struct nlmsghdr *hdr, struct nl_pstate *npt, int cmd)
panic("Unexpected command %d", cmd);
}
- if (! nlmsg_reply(nw, hdr, sizeof(struct genlmsghdr)))
- return (ENOMEM);
+ if (! nlmsg_reply(nw, hdr, sizeof(struct genlmsghdr))) {
+ error = ENOMEM;
+ goto out;
+ }
ghdr_new = nlmsg_reserve_object(nw, struct genlmsghdr);
ghdr_new->cmd = cmd;
@@ -3162,8 +3164,10 @@ pf_handle_trans(struct nlmsghdr *hdr, struct nl_pstate *npt, int cmd)
nlattr_add_trans(nw, PF_TR_TRANS, e);
}
- if (! nlmsg_end(nw))
- return (ENOMEM);
+ if (! nlmsg_end(nw)) {
+ error = ENOMEM;
+ goto out;
+ }
out:
pf_trans_free(&attrs);