radix tree test suite: Fix split/join memory leaks

The last of the memory leaks in the test suite was a couple of places in
the split/join testing where I forgot to free the element being removed
from the tree.

Signed-off-by: Matthew Wilcox <mawilcox@microsoft.com>
Reviewed-by: Rehas Sachdeva <aquannie@gmail.com>
This commit is contained in:
Matthew Wilcox 2017-01-29 02:00:31 -05:00
parent 6da0396cac
commit 3b7869c31f

View file

@ -356,6 +356,10 @@ void multiorder_tagged_iteration(void)
item_kill_tree(&tree); item_kill_tree(&tree);
} }
/*
* Basic join checks: make sure we can't find an entry in the tree after
* a larger entry has replaced it
*/
static void multiorder_join1(unsigned long index, static void multiorder_join1(unsigned long index,
unsigned order1, unsigned order2) unsigned order1, unsigned order2)
{ {
@ -374,6 +378,10 @@ static void multiorder_join1(unsigned long index,
item_kill_tree(&tree); item_kill_tree(&tree);
} }
/*
* Check that the accounting of exceptional entries is handled correctly
* by joining an exceptional entry to a normal pointer.
*/
static void multiorder_join2(unsigned order1, unsigned order2) static void multiorder_join2(unsigned order1, unsigned order2)
{ {
RADIX_TREE(tree, GFP_KERNEL); RADIX_TREE(tree, GFP_KERNEL);
@ -387,6 +395,9 @@ static void multiorder_join2(unsigned order1, unsigned order2)
assert(item2 == (void *)0x12UL); assert(item2 == (void *)0x12UL);
assert(node->exceptional == 1); assert(node->exceptional == 1);
item2 = radix_tree_lookup(&tree, 0);
free(item2);
radix_tree_join(&tree, 0, order1, item1); radix_tree_join(&tree, 0, order1, item1);
item2 = __radix_tree_lookup(&tree, 1 << order2, &node, NULL); item2 = __radix_tree_lookup(&tree, 1 << order2, &node, NULL);
assert(item2 == item1); assert(item2 == item1);
@ -472,6 +483,7 @@ static void __multiorder_split(int old_order, int new_order)
void **slot; void **slot;
struct radix_tree_iter iter; struct radix_tree_iter iter;
unsigned alloc; unsigned alloc;
struct item *item;
radix_tree_preload(GFP_KERNEL); radix_tree_preload(GFP_KERNEL);
assert(item_insert_order(&tree, 0, old_order) == 0); assert(item_insert_order(&tree, 0, old_order) == 0);
@ -480,7 +492,7 @@ static void __multiorder_split(int old_order, int new_order)
/* Wipe out the preloaded cache or it'll confuse check_mem() */ /* Wipe out the preloaded cache or it'll confuse check_mem() */
radix_tree_cpu_dead(0); radix_tree_cpu_dead(0);
radix_tree_tag_set(&tree, 0, 2); item = radix_tree_tag_set(&tree, 0, 2);
radix_tree_split_preload(old_order, new_order, GFP_KERNEL); radix_tree_split_preload(old_order, new_order, GFP_KERNEL);
alloc = nr_allocated; alloc = nr_allocated;
@ -493,6 +505,7 @@ static void __multiorder_split(int old_order, int new_order)
radix_tree_preload_end(); radix_tree_preload_end();
item_kill_tree(&tree); item_kill_tree(&tree);
free(item);
} }
static void __multiorder_split2(int old_order, int new_order) static void __multiorder_split2(int old_order, int new_order)