]> git.karo-electronics.de Git - linux-beck.git/commitdiff
netfilter: unregister nf hooks, matches and targets in the reverse order
authorChangli Gao <xiaosuo@gmail.com>
Mon, 4 Oct 2010 20:24:12 +0000 (22:24 +0200)
committerPatrick McHardy <kaber@trash.net>
Mon, 4 Oct 2010 20:24:12 +0000 (22:24 +0200)
Since we register nf hooks, matches and targets in order, we'd better
unregister them in the reverse order.

Signed-off-by: Changli Gao <xiaosuo@gmail.com>
Signed-off-by: Patrick McHardy <kaber@trash.net>
net/netfilter/core.c
net/netfilter/x_tables.c

index 78b505d33bfb42cdf1033be323c2fdb1a359a833..8f014f22d132d17e7c79ce0aa727463e3dbd7941 100644 (file)
@@ -105,10 +105,8 @@ EXPORT_SYMBOL(nf_register_hooks);
 
 void nf_unregister_hooks(struct nf_hook_ops *reg, unsigned int n)
 {
-       unsigned int i;
-
-       for (i = 0; i < n; i++)
-               nf_unregister_hook(&reg[i]);
+       while (n-- > 0)
+               nf_unregister_hook(&reg[n]);
 }
 EXPORT_SYMBOL(nf_unregister_hooks);
 
index e34622fa000357c5e24eeddd2aad835d616fd8ce..80463507420edffe34544074be18b891928c7dc5 100644 (file)
@@ -116,10 +116,8 @@ EXPORT_SYMBOL(xt_register_targets);
 void
 xt_unregister_targets(struct xt_target *target, unsigned int n)
 {
-       unsigned int i;
-
-       for (i = 0; i < n; i++)
-               xt_unregister_target(&target[i]);
+       while (n-- > 0)
+               xt_unregister_target(&target[n]);
 }
 EXPORT_SYMBOL(xt_unregister_targets);
 
@@ -174,10 +172,8 @@ EXPORT_SYMBOL(xt_register_matches);
 void
 xt_unregister_matches(struct xt_match *match, unsigned int n)
 {
-       unsigned int i;
-
-       for (i = 0; i < n; i++)
-               xt_unregister_match(&match[i]);
+       while (n-- > 0)
+               xt_unregister_match(&match[n]);
 }
 EXPORT_SYMBOL(xt_unregister_matches);