From: Piyush Pangtey <gokuvsvegita@gmail.com>
To: Florian Westphal <fw@strlen.de>
Cc: netfilter-devel@vger.kernel.org
Subject: Re: [RFC] nft: Remove memory-leak
Date: Mon, 14 Mar 2016 14:18:57 +0530 [thread overview]
Message-ID: <56E67AF9.1030105@gmail.com> (raw)
In-Reply-To: <20160313202256.GD1548@breakpoint.cc>
On Monday 14 March 2016 01:52 AM, Florian Westphal wrote:
> Piyush Pangtey <gokuvsvegita@gmail.com> wrote:
>> Memory leak due to the absence of matching free :
>> ==4797== 189 bytes in 27 blocks are definitely lost in loss record 22 of 51
>> ==4797== at 0x4C2AB80: malloc (in
>> /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
>> ==4797== by 0x57A3839: strdup (strdup.c:42)
>> ==4797== by 0x41C00D: xstrdup (utils.c:64)
>> ==4797== by 0x411E4B: netlink_delinearize_chain.isra.3 (netlink.c:717)
>> ==4797== by 0x411F20: list_chain_cb (netlink.c:748)
>> ==4797== by 0x504A943: nft_chain_list_foreach (chain.c:1015)
>> ==4797== by 0x41455E: netlink_list_chains (netlink.c:771)
>> ==4797== by 0x4078EF: cache_init_objects (rule.c:90)
>> ==4797== by 0x4078EF: cache_init (rule.c:130)
>> ==4797== by 0x4078EF: cache_update (rule.c:147)
>> ==4797== by 0x40FB09: cmd_evaluate (evaluate.c:2475)
>> ==4797== by 0x4296BC: nft_parse (parser_bison.y:655)
>> ==4797== by 0x4064CC: nft_run (main.c:231)
>> ==4797== by 0x42CE57: cli_complete (cli.c:124)
> ..
>> --- a/src/netlink.c
>> +++ b/src/netlink.c
>> @@ -714,12 +714,12 @@ static struct chain *netlink_delinearize_chain(struct netlink_ctx *ctx,
>> chain->priority =
>> nftnl_chain_get_s32(nlc, NFTNL_CHAIN_PRIO);
>> chain->type =
>> - xstrdup(nftnl_chain_get_str(nlc, NFTNL_CHAIN_TYPE));
>> + nftnl_chain_get_str(nlc, NFTNL_CHAIN_TYPE);
>
> This looks wrong, nlc lifetime is not tied to chain object.
> Seems chain_free() needs xfree calls for type and ->dev ?
>
Yes.Thanks for commenting.
I tried this as a workaround, because I was not sure about nlc :).
I sent a patch for adding matching free calls to chain_free().
prev parent reply other threads:[~2016-03-14 8:48 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-13 12:08 [RFC] nft: Remove memory-leak Piyush Pangtey
2016-03-13 20:22 ` Florian Westphal
2016-03-14 8:48 ` Piyush Pangtey [this message]
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=56E67AF9.1030105@gmail.com \
--to=gokuvsvegita@gmail.com \
--cc=fw@strlen.de \
--cc=netfilter-devel@vger.kernel.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).