Commit e376ed7c85fe102ff63db2eb8a0c5595f68151fa
Committed by
Linus Torvalds
1 parent
ed8f68669a
arch/sh/kernel/dwarf.c: use rbtree postorder iteration helper instead of solutio…
…n using repeated rb_erase() Use rbtree_postorder_for_each_entry_safe() to destroy the rbtree instead of using repeated rb_erase() calls Signed-off-by: Cody P Schafer <cody@linux.vnet.ibm.com> Cc: Michel Lespinasse <walken@google.com> Cc: Jan Kara <jack@suse.cz> Cc: Paul Mundt <lethal@linux-sh.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Showing 1 changed file with 4 additions and 14 deletions Side-by-side Diff
arch/sh/kernel/dwarf.c
... | ... | @@ -995,29 +995,19 @@ |
995 | 995 | |
996 | 996 | static void dwarf_unwinder_cleanup(void) |
997 | 997 | { |
998 | - struct rb_node **fde_rb_node = &fde_root.rb_node; | |
999 | - struct rb_node **cie_rb_node = &cie_root.rb_node; | |
998 | + struct dwarf_fde *fde, *next_fde; | |
999 | + struct dwarf_cie *cie, *next_cie; | |
1000 | 1000 | |
1001 | 1001 | /* |
1002 | 1002 | * Deallocate all the memory allocated for the DWARF unwinder. |
1003 | 1003 | * Traverse all the FDE/CIE lists and remove and free all the |
1004 | 1004 | * memory associated with those data structures. |
1005 | 1005 | */ |
1006 | - while (*fde_rb_node) { | |
1007 | - struct dwarf_fde *fde; | |
1008 | - | |
1009 | - fde = rb_entry(*fde_rb_node, struct dwarf_fde, node); | |
1010 | - rb_erase(*fde_rb_node, &fde_root); | |
1006 | + rbtree_postorder_for_each_entry_safe(fde, next_fde, &fde_root, node) | |
1011 | 1007 | kfree(fde); |
1012 | - } | |
1013 | 1008 | |
1014 | - while (*cie_rb_node) { | |
1015 | - struct dwarf_cie *cie; | |
1016 | - | |
1017 | - cie = rb_entry(*cie_rb_node, struct dwarf_cie, node); | |
1018 | - rb_erase(*cie_rb_node, &cie_root); | |
1009 | + rbtree_postorder_for_each_entry_safe(cie, next_cie, &cie_root, node) | |
1019 | 1010 | kfree(cie); |
1020 | - } | |
1021 | 1011 | |
1022 | 1012 | kmem_cache_destroy(dwarf_reg_cachep); |
1023 | 1013 | kmem_cache_destroy(dwarf_frame_cachep); |