From: Patrick McHardy <kaber@trash.net>
To: pablo@netfilter.org
Cc: netfilter-devel@vger.kernel.org
Subject: [PATCH] netlink: fix memory leaks
Date: Sun, 11 Jan 2015 08:00:09 +0000 [thread overview]
Message-ID: <1420963209-19954-1-git-send-email-kaber@trash.net> (raw)
Fix two memory leaks in netlink event monitor. Also fix a leak related
to all sets, the ->init expression is not freed.
Signed-off-by: Patrick McHardy <kaber@trash.net>
---
src/netlink.c | 5 ++++-
src/rule.c | 2 ++
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/src/netlink.c b/src/netlink.c
index feaea19..5347372 100644
--- a/src/netlink.c
+++ b/src/netlink.c
@@ -1724,8 +1724,10 @@ static int netlink_events_set_cb(const struct nlmsghdr *nlh, int type,
case NFT_MSG_NEWSET:
printf("add ");
set = netlink_delinearize_set(monh->ctx, nls);
- if (set == NULL)
+ if (set == NULL) {
+ nft_set_free(nls);
return MNL_CB_ERROR;
+ }
set_print_plain(set);
set_free(set);
printf("\n");
@@ -1940,6 +1942,7 @@ static void netlink_events_cache_addset(struct netlink_mon_handler *monh,
t = table_lookup(&s->handle);
if (t == NULL) {
fprintf(stderr, "W: Unable to cache set: table not found.\n");
+ set_free(s);
goto out;
}
diff --git a/src/rule.c b/src/rule.c
index 9576664..dd39e8a 100644
--- a/src/rule.c
+++ b/src/rule.c
@@ -74,6 +74,8 @@ void set_free(struct set *set)
{
if (--set->refcnt > 0)
return;
+ if (set->init != NULL)
+ expr_free(set->init);
handle_free(&set->handle);
xfree(set);
}
--
2.1.0
reply other threads:[~2015-01-11 8:00 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1420963209-19954-1-git-send-email-kaber@trash.net \
--to=kaber@trash.net \
--cc=netfilter-devel@vger.kernel.org \
--cc=pablo@netfilter.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).