Skip to content

Commit

Permalink
[PKT_SCHED] ematch: tcf_em_destroy robustness
Browse files Browse the repository at this point in the history
Make the code in tcf_em_tree_destroy more robust and cleaner:
 * Don't need to cast pointer to kfree() or avoid passing NULL.
 * After freeing the tree, clear the pointer to avoid possible problems
from repeated free.

Signed-off-by: Stephen Hemminger <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
Stephen Hemminger authored and davem330 committed Feb 10, 2008
1 parent ed7af3b commit 954415e
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions net/sched/ematch.c
Original file line number Diff line number Diff line change
Expand Up @@ -409,14 +409,15 @@ void tcf_em_tree_destroy(struct tcf_proto *tp, struct tcf_ematch_tree *tree)
if (em->ops) {
if (em->ops->destroy)
em->ops->destroy(tp, em);
else if (!tcf_em_is_simple(em) && em->data)
kfree((void *) em->data);
else if (!tcf_em_is_simple(em))
kfree(em->data);
module_put(em->ops->owner);
}
}

tree->hdr.nmatches = 0;
kfree(tree->matches);
tree->matches = NULL;
}
EXPORT_SYMBOL(tcf_em_tree_destroy);

Expand Down

0 comments on commit 954415e

Please sign in to comment.