Skip to content

Commit

Permalink
net/netfilter/ipset/ip_set_hash_netiface.c: use rbtree postorder iter…
Browse files Browse the repository at this point in the history
…ation instead of opencoding

Use rbtree_postorder_for_each_entry_safe() to destroy the rbtree instead
of opencoding an alternate postorder iteration that modifies the tree

Signed-off-by: Cody P Schafer <cody@linux.vnet.ibm.com>
Cc: Michel Lespinasse <walken@google.com>
Cc: Jan Kara <jack@suse.cz>
Cc: Pablo Neira Ayuso <pablo@netfilter.org>
Cc: Patrick McHardy <kaber@trash.net>
Cc: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
Cc: "David S. Miller" <davem@davemloft.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Cody P Schafer authored and Linus Torvalds committed Jan 24, 2014
1 parent 964fe94 commit b182837
Showing 1 changed file with 4 additions and 23 deletions.
27 changes: 4 additions & 23 deletions net/netfilter/ipset/ip_set_hash_netiface.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,31 +46,12 @@ struct iface_node {
static void
rbtree_destroy(struct rb_root *root)
{
struct rb_node *p, *n = root->rb_node;
struct iface_node *node;

/* Non-recursive destroy, like in ext3 */
while (n) {
if (n->rb_left) {
n = n->rb_left;
continue;
}
if (n->rb_right) {
n = n->rb_right;
continue;
}
p = rb_parent(n);
node = rb_entry(n, struct iface_node, node);
if (!p)
*root = RB_ROOT;
else if (p->rb_left == n)
p->rb_left = NULL;
else if (p->rb_right == n)
p->rb_right = NULL;
struct iface_node *node, *next;

rbtree_postorder_for_each_entry_safe(node, next, root, node)
kfree(node);
n = p;
}

*root = RB_ROOT;
}

static int
Expand Down

0 comments on commit b182837

Please sign in to comment.