aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Wilcox <mawilcox@microsoft.com>2017-01-29 02:00:31 -0500
committerMatthew Wilcox <mawilcox@microsoft.com>2017-02-13 21:44:08 -0500
commit3b7869c31f9358a63e502c8c5c7664daf1c6d8b0 (patch)
treebde89d986ede39d505af0b2a544106948dee116f
parent6da0396cac7692b6667c09382a746593fff90e6d (diff)
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>
-rw-r--r--tools/testing/radix-tree/multiorder.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/tools/testing/radix-tree/multiorder.c b/tools/testing/radix-tree/multiorder.c
index 72d80f7059d3..06c71178d07d 100644
--- a/tools/testing/radix-tree/multiorder.c
+++ b/tools/testing/radix-tree/multiorder.c
@@ -356,6 +356,10 @@ void multiorder_tagged_iteration(void)
356 item_kill_tree(&tree); 356 item_kill_tree(&tree);
357} 357}
358 358
359/*
360 * Basic join checks: make sure we can't find an entry in the tree after
361 * a larger entry has replaced it
362 */
359static void multiorder_join1(unsigned long index, 363static void multiorder_join1(unsigned long index,
360 unsigned order1, unsigned order2) 364 unsigned order1, unsigned order2)
361{ 365{
@@ -374,6 +378,10 @@ static void multiorder_join1(unsigned long index,
374 item_kill_tree(&tree); 378 item_kill_tree(&tree);
375} 379}
376 380
381/*
382 * Check that the accounting of exceptional entries is handled correctly
383 * by joining an exceptional entry to a normal pointer.
384 */
377static void multiorder_join2(unsigned order1, unsigned order2) 385static void multiorder_join2(unsigned order1, unsigned order2)
378{ 386{
379 RADIX_TREE(tree, GFP_KERNEL); 387 RADIX_TREE(tree, GFP_KERNEL);
@@ -387,6 +395,9 @@ static void multiorder_join2(unsigned order1, unsigned order2)
387 assert(item2 == (void *)0x12UL); 395 assert(item2 == (void *)0x12UL);
388 assert(node->exceptional == 1); 396 assert(node->exceptional == 1);
389 397
398 item2 = radix_tree_lookup(&tree, 0);
399 free(item2);
400
390 radix_tree_join(&tree, 0, order1, item1); 401 radix_tree_join(&tree, 0, order1, item1);
391 item2 = __radix_tree_lookup(&tree, 1 << order2, &node, NULL); 402 item2 = __radix_tree_lookup(&tree, 1 << order2, &node, NULL);
392 assert(item2 == item1); 403 assert(item2 == item1);
@@ -472,6 +483,7 @@ static void __multiorder_split(int old_order, int new_order)
472 void **slot; 483 void **slot;
473 struct radix_tree_iter iter; 484 struct radix_tree_iter iter;
474 unsigned alloc; 485 unsigned alloc;
486 struct item *item;
475 487
476 radix_tree_preload(GFP_KERNEL); 488 radix_tree_preload(GFP_KERNEL);
477 assert(item_insert_order(&tree, 0, old_order) == 0); 489 assert(item_insert_order(&tree, 0, old_order) == 0);
@@ -480,7 +492,7 @@ static void __multiorder_split(int old_order, int new_order)
480 /* Wipe out the preloaded cache or it'll confuse check_mem() */ 492 /* Wipe out the preloaded cache or it'll confuse check_mem() */
481 radix_tree_cpu_dead(0); 493 radix_tree_cpu_dead(0);
482 494
483 radix_tree_tag_set(&tree, 0, 2); 495 item = radix_tree_tag_set(&tree, 0, 2);
484 496
485 radix_tree_split_preload(old_order, new_order, GFP_KERNEL); 497 radix_tree_split_preload(old_order, new_order, GFP_KERNEL);
486 alloc = nr_allocated; 498 alloc = nr_allocated;
@@ -493,6 +505,7 @@ static void __multiorder_split(int old_order, int new_order)
493 radix_tree_preload_end(); 505 radix_tree_preload_end();
494 506
495 item_kill_tree(&tree); 507 item_kill_tree(&tree);
508 free(item);
496} 509}
497 510
498static void __multiorder_split2(int old_order, int new_order) 511static void __multiorder_split2(int old_order, int new_order)