Skip to content

Commit

Permalink
lib/btree.c: fix leak of whole btree nodes
Browse files Browse the repository at this point in the history
I use btree from 3.14-rc2 in my own module.  When the btree module is
removed, a warning arises:

 kmem_cache_destroy btree_node: Slab cache still has objects
 CPU: 13 PID: 9150 Comm: rmmod Tainted: GF          O 3.14.0-rc2 #1
 Hardware name: Inspur NF5270M3/NF5270M3, BIOS CHEETAH_2.1.3 09/10/2013
 Call Trace:
   dump_stack+0x49/0x5d
   kmem_cache_destroy+0xcf/0xe0
   btree_module_exit+0x10/0x12 [btree]
   SyS_delete_module+0x198/0x1f0
   system_call_fastpath+0x16/0x1b

The cause is that it doesn't release the last btree node, when height = 1
and fill = 1.

[[email protected]: remove unneeded test of NULL]
Signed-off-by: Minfei Huang <[email protected]>
Cc: Joern Engel <[email protected]>
Cc: Johannes Berg <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Minfei Huang authored and torvalds committed Jun 4, 2014
1 parent 3f623eb commit c75b53a
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions lib/btree.c
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ EXPORT_SYMBOL_GPL(btree_init);

void btree_destroy(struct btree_head *head)
{
mempool_free(head->node, head->mempool);
mempool_destroy(head->mempool);
head->mempool = NULL;
}
Expand Down

0 comments on commit c75b53a

Please sign in to comment.