[PATCH] netfilter: nf_tables: Release memory obtained by kasprintf

Subsystems: netfilter, networking [general], the rest

STALE3263d

2 messages, 2 authors, 2017-10-03 · open the first message on its own page

[PATCH] netfilter: nf_tables: Release memory obtained by kasprintf

From: Arvind Yadav <hidden>
Date: 2017-09-20 07:02:29

Free memory region, if nf_tables_set_alloc_name is not successful.

Signed-off-by: Arvind Yadav <redacted>
---
 net/netfilter/nf_tables_api.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c
index 9299271..393e37e 100644
--- a/net/netfilter/nf_tables_api.c
+++ b/net/netfilter/nf_tables_api.c
@@ -2741,8 +2741,10 @@ static int nf_tables_set_alloc_name(struct nft_ctx *ctx, struct nft_set *set,
 	list_for_each_entry(i, &ctx->table->sets, list) {
 		if (!nft_is_active_next(ctx->net, i))
 			continue;
-		if (!strcmp(set->name, i->name))
+		if (!strcmp(set->name, i->name)) {
+			kfree(set->name);
 			return -ENFILE;
+		}
 	}
 	return 0;
 }
-- 
1.9.1

Re: [PATCH] netfilter: nf_tables: Release memory obtained by kasprintf

From: Pablo Neira Ayuso <pablo@netfilter.org>
Date: 2017-10-03 13:23:16

On Wed, Sep 20, 2017 at 12:31:28PM +0530, Arvind Yadav wrote:
Free memory region, if nf_tables_set_alloc_name is not successful.
Applied, thanks.

I have added this tag to this patch:

Fixes: 387454901bd6 ("netfilter: nf_tables: Allow set names of up to 255 chars")
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help