netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH nft,v2] libnftables: memleak when list of commands is empty
@ 2019-09-27  6:42 Pablo Neira Ayuso
  2019-09-27  7:58 ` Jeremy Sowden
  0 siblings, 1 reply; 2+ messages in thread
From: Pablo Neira Ayuso @ 2019-09-27  6:42 UTC (permalink / raw)
  To: netfilter-devel; +Cc: jeremy

==9946== 200,807 (40 direct, 200,767 indirect) bytes in 1 blocks are definitely lost in loss record 4 of 4
==9946==    at 0x4837B65: calloc (vg_replace_malloc.c:762)
==9946==    by 0x4F28216: nftnl_batch_alloc (batch.c:66)
==9946==    by 0x48A33E8: mnl_batch_init (mnl.c:164)
==9946==    by 0x48A736F: nft_netlink.isra.0 (libnftables.c:29)
==9946==    by 0x48A7D03: nft_run_cmd_from_filename (libnftables.c:508)
==9946==    by 0x10A621: main (main.c:328)

Fixes: fc6d0f8b0cb1 ("libnftables: get rid of repeated initialization of netlink_ctx")
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
v2: better commit description and title.

 src/libnftables.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/libnftables.c b/src/libnftables.c
index a19636b22683..e20372438db6 100644
--- a/src/libnftables.c
+++ b/src/libnftables.c
@@ -34,7 +34,7 @@ static int nft_netlink(struct nft_ctx *nft,
 	int ret = 0;
 
 	if (list_empty(cmds))
-		return 0;
+		goto out;
 
 	batch_seqnum = mnl_batch_begin(ctx.batch, mnl_seqnum_alloc(&seqnum));
 	list_for_each_entry(cmd, cmds, list) {
-- 
2.11.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH nft,v2] libnftables: memleak when list of commands is empty
  2019-09-27  6:42 [PATCH nft,v2] libnftables: memleak when list of commands is empty Pablo Neira Ayuso
@ 2019-09-27  7:58 ` Jeremy Sowden
  0 siblings, 0 replies; 2+ messages in thread
From: Jeremy Sowden @ 2019-09-27  7:58 UTC (permalink / raw)
  To: Pablo Neira Ayuso; +Cc: netfilter-devel

[-- Attachment #1: Type: text/plain, Size: 1314 bytes --]

On 2019-09-27, at 08:42:51 +0200, Pablo Neira Ayuso wrote:
> ==9946== 200,807 (40 direct, 200,767 indirect) bytes in 1 blocks are definitely lost in loss record 4 of 4
> ==9946==    at 0x4837B65: calloc (vg_replace_malloc.c:762)
> ==9946==    by 0x4F28216: nftnl_batch_alloc (batch.c:66)
> ==9946==    by 0x48A33E8: mnl_batch_init (mnl.c:164)
> ==9946==    by 0x48A736F: nft_netlink.isra.0 (libnftables.c:29)
> ==9946==    by 0x48A7D03: nft_run_cmd_from_filename (libnftables.c:508)
> ==9946==    by 0x10A621: main (main.c:328)
>
> Fixes: fc6d0f8b0cb1 ("libnftables: get rid of repeated initialization of netlink_ctx")

Whoops.  Thanks for fixing this.

> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>

Acked-by: Jeremy Sowden <jeremy@azazel.net>

> ---
> v2: better commit description and title.
>
>  src/libnftables.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/src/libnftables.c b/src/libnftables.c
> index a19636b22683..e20372438db6 100644
> --- a/src/libnftables.c
> +++ b/src/libnftables.c
> @@ -34,7 +34,7 @@ static int nft_netlink(struct nft_ctx *nft,
>  	int ret = 0;
>
>  	if (list_empty(cmds))
> -		return 0;
> +		goto out;
>
>  	batch_seqnum = mnl_batch_begin(ctx.batch, mnl_seqnum_alloc(&seqnum));
>  	list_for_each_entry(cmd, cmds, list) {
> --
> 2.11.0
>
>

J.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-09-27  7:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-27  6:42 [PATCH nft,v2] libnftables: memleak when list of commands is empty Pablo Neira Ayuso
2019-09-27  7:58 ` Jeremy Sowden

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).