netfilter: nf_tables: Release memory obtained by kasprintf
authorArvind Yadav <arvind.yadav.cs@gmail.com>
Wed, 20 Sep 2017 07:01:28 +0000 (12:31 +0530)
committerPablo Neira Ayuso <pablo@netfilter.org>
Tue, 3 Oct 2017 13:21:19 +0000 (15:21 +0200)
Free memory region, if nf_tables_set_alloc_name is not successful.

Fixes: 387454901bd6 ("netfilter: nf_tables: Allow set names of up to 255 chars")
Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
net/netfilter/nf_tables_api.c

index f98ca8c6aa59d112495de749009848dbe4e90465..34adedcb239ea2daa9370d2a3765c8af742b5ba6 100644 (file)
@@ -2741,8 +2741,10 @@ cont:
        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;
 }