Skip to contentSkip to conversation

Btrfs: fix inode leak on kmalloc failure in tree-log.c

PATCH New Filipe David Borba Manana 1 participant 1 message Aug 4, 2013 Btrfs file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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.

---
 fs/btrfs/tree-log.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
fs/btrfs/tree-log.c +4 -2
index ff60d89..6797a93 100644
@@ -1536,8 +1536,10 @@ static noinline int replay_one_name(struct btrfs_trans_handle *trans,
 
 	name_len = btrfs_dir_name_len(eb, di);
 	name = kmalloc(name_len, GFP_NOFS);
-	if (!name)
-		return -ENOMEM;
+	if (!name) {
+		ret = -ENOMEM;
+		goto out;
+	}
 
 	log_type = btrfs_dir_type(eb, di);
 	read_extent_buffer(eb, name, (unsigned long)(di + 1),
Signature · 1 line
1.7.9.5