From: "Geyslan G. Bem" <geyslan@gmail.com>
To: chris.mason@fusionio.com
Cc: linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org,
jbacik@fusionio.com, joe@perches.com, kernel-br@googlegroups.com,
"Geyslan G. Bem" <geyslan@gmail.com>
Subject: [PATCH v4] btrfs: Fix memory leakage in the tree-log.c
Date: Wed, 9 Oct 2013 23:01:35 -0300 [thread overview]
Message-ID: <1381370495-13702-1-git-send-email-geyslan@gmail.com> (raw)
When 'dir' is NULL, after calling extref_get_fields(), add_inode_ref()
can be returning without freeing the 'name' pointer.
Added kfree when necessary.
Signed-off-by: Geyslan G. Bem <geyslan@gmail.com>
---
fs/btrfs/tree-log.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c
index 79f057c..63c0b72 100644
--- a/fs/btrfs/tree-log.c
+++ b/fs/btrfs/tree-log.c
@@ -1169,8 +1169,11 @@ static noinline int add_inode_ref(struct btrfs_trans_handle *trans,
*/
if (!dir)
dir = read_one_inode(root, parent_objectid);
- if (!dir)
+ if (!dir) {
+ if (!ret)
+ kfree(name);
return -ENOENT;
+ }
} else {
ret = ref_get_fields(eb, ref_ptr, &namelen, &name,
&ref_index);
--
1.8.4
next reply other threads:[~2013-10-10 2:05 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-10-10 2:01 Geyslan G. Bem [this message]
2013-10-10 10:41 ` [PATCH v4] btrfs: Fix memory leakage in the tree-log.c Stefan Behrens
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=1381370495-13702-1-git-send-email-geyslan@gmail.com \
--to=geyslan@gmail.com \
--cc=chris.mason@fusionio.com \
--cc=jbacik@fusionio.com \
--cc=joe@perches.com \
--cc=kernel-br@googlegroups.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=linux-kernel@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).