[PATCH xtables-addons 7/8] xt_condition: don't delete variables in `condition_net_exit`.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



`condition_mt_destroy` will be called for every match anyway, so we may
as well do the clean-up then, rather than duplicating it.

Signed-off-by: Jeremy Sowden <jeremy@xxxxxxxxxx>
---
 extensions/xt_condition.c | 16 ++--------------
 1 file changed, 2 insertions(+), 14 deletions(-)

diff --git a/extensions/xt_condition.c b/extensions/xt_condition.c
index cec232e30f1f..0b0508b7723c 100644
--- a/extensions/xt_condition.c
+++ b/extensions/xt_condition.c
@@ -188,13 +188,11 @@ static void condition_mt_destroy(const struct xt_mtdtor_param *par)
 	struct condition_variable *var = info->condvar;
 	struct condition_net *cnet = condition_pernet(par->net);
 
-	if (!cnet->proc_net_condition)
-		return;
-
 	mutex_lock(&cnet->proc_lock);
 	if (--var->refcount == 0) {
 		list_del(&var->list);
-		remove_proc_entry(var->name, cnet->proc_net_condition);
+		if (cnet->proc_net_condition)
+			remove_proc_entry(var->name, cnet->proc_net_condition);
 		mutex_unlock(&cnet->proc_lock);
 		kfree(var);
 		return;
@@ -242,17 +240,8 @@ static int __net_init condition_net_init(struct net *net)
 static void __net_exit condition_net_exit(struct net *net)
 {
 	struct condition_net *condition_net = condition_pernet(net);
-	struct list_head *pos, *q;
-	struct condition_variable *var = NULL;
 
 	remove_proc_subtree(dir_name, net->proc_net);
-	mutex_lock(&condition_net->proc_lock);
-	list_for_each_safe(pos, q, &condition_net->conditions_list) {
-		var = list_entry(pos, struct condition_variable, list);
-		list_del(pos);
-		kfree(var);
-	}
-	mutex_unlock(&condition_net->proc_lock);
 	condition_net->proc_net_condition = NULL;
 }
 
@@ -263,7 +252,6 @@ static struct pernet_operations condition_net_ops = {
 	.size   = sizeof(struct condition_net),
 };
 
-
 static int __init condition_mt_init(void)
 {
 	int ret;
-- 
2.32.0




[Index of Archives]     [Netfitler Users]     [Berkeley Packet Filter]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux