From: Dave Anderson <anderson@redhat.com>
To: linux-kernel@vger.kernel.org
Cc: zippel@linux-m68k.org, Dave Anderson <anderson@redhat.com>
Subject: [PATCH] HFS: fix memory leak when unmounting
Date: Thu, 26 Mar 2009 16:26:59 -0400 [thread overview]
Message-ID: <49CBE513.80205@redhat.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 307 bytes --]
When an HFS filesystem is unmounted, it leaks a 2-page
bitmap. Also, under extreme memory pressure, it's possible
that hfs_releasepage() may use a tree pointer that has not
been initialized, and if so, the release request should
just be rejected.
Signed-off-by: Dave Anderson <anderson@redhat.com>
[-- Attachment #2: hfs-git.patch --]
[-- Type: text/x-patch, Size: 818 bytes --]
diff --git a/fs/hfs/inode.c b/fs/hfs/inode.c
index 9435dda..a1cbff2 100644
--- a/fs/hfs/inode.c
+++ b/fs/hfs/inode.c
@@ -70,6 +70,10 @@ static int hfs_releasepage(struct page *page, gfp_t mask)
BUG();
return 0;
}
+
+ if (!tree)
+ return 0;
+
if (tree->node_size >= PAGE_CACHE_SIZE) {
nidx = page->index >> (tree->node_size_shift - PAGE_CACHE_SHIFT);
spin_lock(&tree->hash_lock);
diff --git a/fs/hfs/mdb.c b/fs/hfs/mdb.c
index 36ca2e1..369f2af 100644
--- a/fs/hfs/mdb.c
+++ b/fs/hfs/mdb.c
@@ -349,6 +349,10 @@ void hfs_mdb_put(struct super_block *sb)
if (HFS_SB(sb)->nls_disk)
unload_nls(HFS_SB(sb)->nls_disk);
+ /* free the bitmap page(s) */
+ if (HFS_SB(sb)->bitmap)
+ free_pages((unsigned long)HFS_SB(sb)->bitmap, PAGE_SIZE < 8192 ? 1 : 0);
+
kfree(HFS_SB(sb));
sb->s_fs_info = NULL;
}
next reply other threads:[~2009-03-26 20:27 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-03-26 20:26 Dave Anderson [this message]
2009-03-26 23:19 ` [PATCH] HFS: fix memory leak when unmounting Eugene Teo
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=49CBE513.80205@redhat.com \
--to=anderson@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=zippel@linux-m68k.org \
/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