Skip to contentSkip to conversation

netfilter: nf_tables: fix userdata memleak

PATCH Applied Jose M. Guisado Gomez 2 participants 2 messages Sep 27, 2020 – Sep 30, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 netfilter: nf_tables: fix userdata memleak

When userdata was introduced for tables and objects its allocation was only freed inside the error path of the new{table, object} functions.

Free user data inside corresponding destroy functions for tables and objects.

Fixes b131c96496b3 ("netfilter: nf_tables: add userdata support for nft_object")
Fixes 7a81575b806e ("netfilter: nf_tables: add userdata attributes to nft_table")
---
 net/netfilter/nf_tables_api.c | 2 ++
 1 file changed, 2 insertions(+)
net/netfilter/nf_tables_api.c +2 -0
index 84c0c1aaae99..b3c3c3fc1969 100644
@@ -1211,6 +1211,7 @@ static void nf_tables_table_destroy(struct nft_ctx *ctx)
 
 	rhltable_destroy(&ctx->table->chains_ht);
 	kfree(ctx->table->name);
+	kfree(ctx->table->udata);
 	kfree(ctx->table);
 }
 
@@ -6231,6 +6232,7 @@ static void nft_obj_destroy(const struct nft_ctx *ctx, struct nft_object *obj)
 
 	module_put(obj->ops->type->owner);
 	kfree(obj->key.name);
+	kfree(obj->udata);
 	kfree(obj);
 }
 
Signature · 1 line
2.27.0
maintainer Applied
#1 lore raw
Quoted 5 lines · Jose M. Guisado Gomez

When userdata was introduced for tables and objects its allocation was only freed inside the error path of the new{table, object} functions.

Free user data inside corresponding destroy functions for tables and objects.

Applied, thanks.