From: Weijie Yang <weijie.yang.kh@gmail.com>
To: Minchan Kim <minchan@kernel.org>, Bob Liu <bob.liu@oracle.com>,
sjenning@linux.vnet.ibm.com
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org,
weijie.yang@samsung.com
Subject: [PATCH 1/4] zswap bugfix: memory leaks when re-swapon
Date: Fri, 23 Aug 2013 19:03:37 +0800 [thread overview]
Message-ID: <CAL1ERfPzB=CvKJ6kAq2YYTkkg-EgSOWRyfSFWkvKp8ZdQkCDxA@mail.gmail.com> (raw)
zswap_tree is not freed when swapoff, and it got re-kzalloc in swapon,
memory leak occurs.
Add check statement in zswap_frontswap_init so that zswap_tree is
inited only once.
---
mm/zswap.c | 5 +++++
1 files changed, 5 insertions(+), 0 deletions(-)
diff --git a/mm/zswap.c b/mm/zswap.c
index deda2b6..1cf1c07 100644
--- a/mm/zswap.c
+++ b/mm/zswap.c
@@ -826,6 +826,11 @@ static void zswap_frontswap_init(unsigned type)
{
struct zswap_tree *tree;
+ if (zswap_trees[type]) {
+ BUG_ON(zswap_trees[type]->rbroot != RB_ROOT); /* invalidate_area set it */
+ return;
+ }
+
tree = kzalloc(sizeof(struct zswap_tree), GFP_KERNEL);
if (!tree)
goto err;
--
1.7.0.4
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next reply other threads:[~2013-08-23 11:03 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-08-23 11:03 Weijie Yang [this message]
2013-08-23 15:28 ` Seth Jennings
2013-08-25 12:00 ` Weijie Yang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAL1ERfPzB=CvKJ6kAq2YYTkkg-EgSOWRyfSFWkvKp8ZdQkCDxA@mail.gmail.com' \
--to=weijie.yang.kh@gmail.com \
--cc=bob.liu@oracle.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=minchan@kernel.org \
--cc=sjenning@linux.vnet.ibm.com \
--cc=weijie.yang@samsung.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox