Subject: + lib-btreec-fix-leak-of-whole-btree-nodes.patch added to -mm tree To: huangminfei@xxxxxxxxx,joern@xxxxxxxxx,johannes@xxxxxxxxxxxxxxxx From: akpm@xxxxxxxxxxxxxxxxxxxx Date: Thu, 08 May 2014 15:45:05 -0700 The patch titled Subject: lib/btree.c: fix leak of whole btree nodes has been added to the -mm tree. Its filename is lib-btreec-fix-leak-of-whole-btree-nodes.patch This patch should soon appear at http://ozlabs.org/~akpm/mmots/broken-out/lib-btreec-fix-leak-of-whole-btree-nodes.patch and later at http://ozlabs.org/~akpm/mmotm/broken-out/lib-btreec-fix-leak-of-whole-btree-nodes.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/SubmitChecklist when testing your code *** The -mm tree is included into linux-next and is updated there every 3-4 working days ------------------------------------------------------ From: Minfei Huang <huangminfei@xxxxxxxxx> Subject: lib/btree.c: fix leak of whole btree nodes 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 ffff881ff8643b18 ffff881ffdc23ea8 ffffffff815a4ecc 0000000000000000 ffff881ff8643ac0 ffff881ffdc23ec8 ffffffff811610df 0000000000000880 ffffffffa057da60 ffff881ffdc23ed8 ffffffffa057d57c ffff881ffdc23f78 Call Trace: [<ffffffff815a4ecc>] dump_stack+0x49/0x5d [<ffffffff811610df>] kmem_cache_destroy+0xcf/0xe0 [<ffffffffa057d57c>] btree_module_exit+0x10/0x12 [btree] [<ffffffff810d7948>] SyS_delete_module+0x198/0x1f0 [<ffffffff815aac89>] ? retint_swapgs+0xe/0x13 [<ffffffff810a561d>] ? trace_hardirqs_on_caller+0xfd/0x1c0 [<ffffffff812addde>] ? trace_hardirqs_on_thunk+0x3a/0x3f [<ffffffff815b3652>] system_call_fastpath+0x16/0x1b The cause is that it doesn't release the last btree node, when height = 1 and fill = 1. Signed-off-by: Minfei Huang <huangminfei@xxxxxxxxx> Cc: Joern Engel <joern@xxxxxxxxx> Cc: Johannes Berg <johannes@xxxxxxxxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- lib/btree.c | 2 ++ 1 file changed, 2 insertions(+) diff -puN lib/btree.c~lib-btreec-fix-leak-of-whole-btree-nodes lib/btree.c --- a/lib/btree.c~lib-btreec-fix-leak-of-whole-btree-nodes +++ a/lib/btree.c @@ -198,6 +198,8 @@ EXPORT_SYMBOL_GPL(btree_init); void btree_destroy(struct btree_head *head) { + if (head->node) + mempool_free(head->node, head->mempool); mempool_destroy(head->mempool); head->mempool = NULL; } _ Patches currently in -mm which might be from huangminfei@xxxxxxxxx are lib-btreec-fix-leak-of-whole-btree-nodes.patch lib-btreec-fix-leak-of-whole-btree-nodes-fix.patch -- To unsubscribe from this list: send the line "unsubscribe mm-commits" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html