aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFilipe David Borba Manana <fdmanana@gmail.com>2013-08-04 14:58:57 -0400
committerChris Mason <chris.mason@fusionio.com>2013-09-01 08:04:53 -0400
commit2bac325ea8f117636e6601e66a67d2df58974610 (patch)
treeb1dea569df4e30a89fe6b95b1adc2c26ade2f4f3
parent116e0024c453dfdfacc9278f485dabc9c63a4ac4 (diff)
Btrfs: fix inode leak on kmalloc failure in tree-log.c
In tree-log.c:replay_one_name(), if memory allocation for the name fails, ensure we iput the dir inode we got before before we return. Signed-off-by: Filipe David Borba Manana <fdmanana@gmail.com> Signed-off-by: Josef Bacik <jbacik@fusionio.com> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
-rw-r--r--fs/btrfs/tree-log.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c
index ff60d8978ae2..6797a931cf62 100644
--- a/fs/btrfs/tree-log.c
+++ b/fs/btrfs/tree-log.c
@@ -1536,8 +1536,10 @@ static noinline int replay_one_name(struct btrfs_trans_handle *trans,
1536 1536
1537 name_len = btrfs_dir_name_len(eb, di); 1537 name_len = btrfs_dir_name_len(eb, di);
1538 name = kmalloc(name_len, GFP_NOFS); 1538 name = kmalloc(name_len, GFP_NOFS);
1539 if (!name) 1539 if (!name) {
1540 return -ENOMEM; 1540 ret = -ENOMEM;
1541 goto out;
1542 }
1541 1543
1542 log_type = btrfs_dir_type(eb, di); 1544 log_type = btrfs_dir_type(eb, di);
1543 read_extent_buffer(eb, name, (unsigned long)(di + 1), 1545 read_extent_buffer(eb, name, (unsigned long)(di + 1),