From: Josef Bacik <josef@redhat.com>
To: linux-btrfs@vger.kernel.org
Subject: [PATCH] Btrfs: fix some memory leak issues
Date: Fri, 28 Jan 2011 17:08:42 -0500 [thread overview]
Message-ID: <1296252522-3260-1-git-send-email-josef@redhat.com> (raw)
My reworking of file.c left a few memory leaks, this patch fixes these up.
Really these are places where before the rework we just BUG()'ed anyway, so it's
not that bad :). Thanks,
Signed-off-by: Josef Bacik <josef@redhat.com>
---
fs/btrfs/file.c | 7 ++++++-
1 files changed, 6 insertions(+), 1 deletions(-)
diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
index 416eee8..8dba070 100644
--- a/fs/btrfs/file.c
+++ b/fs/btrfs/file.c
@@ -876,8 +876,10 @@ static noinline ssize_t __btrfs_buffered_write(struct file *file,
pinned[0] = grab_cache_page(inode->i_mapping, first_index);
if (!PageUptodate(pinned[0])) {
ret = btrfs_readpage(NULL, pinned[0]);
- if (ret)
+ if (ret) {
+ kfree(pages);
return ret;
+ }
wait_on_page_locked(pinned[0]);
} else {
unlock_page(pinned[0]);
@@ -891,6 +893,7 @@ static noinline ssize_t __btrfs_buffered_write(struct file *file,
if (ret) {
if (pinned[0])
page_cache_release(pinned[0]);
+ kfree(pages);
return ret;
}
wait_on_page_locked(pinned[1]);
@@ -965,8 +968,10 @@ again:
dirty_pages, pos,
copied);
if (ret) {
+ WARN_ON(1);
btrfs_delalloc_release_space(inode,
dirty_pages << PAGE_CACHE_SHIFT);
+ btrfs_drop_pages(pages, num_pages);
break;
}
}
--
1.7.2.3
reply other threads:[~2011-01-28 22:08 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=1296252522-3260-1-git-send-email-josef@redhat.com \
--to=josef@redhat.com \
--cc=linux-btrfs@vger.kernel.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;
as well as URLs for NNTP newsgroup(s).