Skip to contentSkip to conversation

btrfs-progs: verify_space_cache: Fix memory leak.

PATCH New chandan 1 participant 1 message Sep 22, 2013 Btrfs file system

lore
Share & tools
lore

chandan

author
#0 lore raw

PATCH 1/1 btrfs-progs: verify_space_cache: Fix memory leak.

Free btrfs_path structure before returning due to failure of calls to btrfs_search_slot() or btrfs_next_leaf() functions.

---
 cmds-check.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
cmds-check.c +7 -2
index e08b79d..c947156 100644
@@ -3227,14 +3227,19 @@ static int verify_space_cache(struct btrfs_root *root,
 	key.type = BTRFS_EXTENT_ITEM_KEY;
 
 	ret = btrfs_search_slot(NULL, root, &key, path, 0, 0);
-	if (ret < 0)
+	if (ret < 0) {
+		btrfs_free_path(path);
 		return ret;
+	}
+
 	ret = 0;
 	while (1) {
 		if (path->slots[0] >= btrfs_header_nritems(path->nodes[0])) {
 			ret = btrfs_next_leaf(root, path);
-			if (ret < 0)
+			if (ret < 0) {
+				btrfs_free_path(path);
 				return ret;
+			}
 			if (ret > 0) {
 				ret = 0;
 				break;
Signature · 1 line
1.8.3.1