All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 01/10] btrfs-progs: fix leak of "path" in btrfs_find_item() error paths
@ 2015-10-19 11:37 Eryu Guan
  2015-10-19 11:37 ` [PATCH 02/10] btrfs-progs: save and return error number correctly in check_chunks_and_extents Eryu Guan
                   ` (10 more replies)
  0 siblings, 11 replies; 19+ messages in thread
From: Eryu Guan @ 2015-10-19 11:37 UTC (permalink / raw)
  To: linux-btrfs; +Cc: Eryu Guan

path needs to be freed before return.

Signed-off-by: Eryu Guan <guaneryu@gmail.com>
---
 ctree.c | 20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/ctree.c b/ctree.c
index e6e5689..1434007 100644
--- a/ctree.c
+++ b/ctree.c
@@ -1058,26 +1058,28 @@ int btrfs_find_item(struct btrfs_root *fs_root, struct btrfs_path *found_path,
 		path = found_path;
 
 	ret = btrfs_search_slot(NULL, fs_root, &key, path, 0, 0);
-	if ((ret < 0) || (found_key == NULL)) {
-		if (path != found_path)
-			btrfs_free_path(path);
-		return ret;
-	}
+	if ((ret < 0) || (found_key == NULL))
+		goto out;
 
 	eb = path->nodes[0];
 	if (ret && path->slots[0] >= btrfs_header_nritems(eb)) {
 		ret = btrfs_next_leaf(fs_root, path);
 		if (ret)
-			return ret;
+			goto out;
 		eb = path->nodes[0];
 	}
 
 	btrfs_item_key_to_cpu(eb, found_key, path->slots[0]);
 	if (found_key->type != key.type ||
-			found_key->objectid != key.objectid)
-		return 1;
+			found_key->objectid != key.objectid) {
+		ret = 1;
+		goto out;
+	}
 
-	return 0;
+out:
+	if (path != found_path)
+		btrfs_free_path(path);
+	return ret;
 }
 
 /*
-- 
2.4.3


^ permalink raw reply related	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2015-10-21 11:35 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-10-19 11:37 [PATCH 01/10] btrfs-progs: fix leak of "path" in btrfs_find_item() error paths Eryu Guan
2015-10-19 11:37 ` [PATCH 02/10] btrfs-progs: save and return error number correctly in check_chunks_and_extents Eryu Guan
2015-10-19 11:37 ` [PATCH 02/10] btrfs-progs: save " Eryu Guan
2015-10-19 13:41   ` David Sterba
2015-10-20 10:28     ` Eryu Guan
2015-10-21  9:26       ` David Sterba
2015-10-19 11:37 ` [PATCH 03/10] btrfs-progs: remove deadcode around metadump_v2 in check_chunk_refs Eryu Guan
2015-10-19 13:45   ` David Sterba
2015-10-19 11:37 ` [PATCH 04/10] btrfs-progs: return -EIO properly in restore_metadump() Eryu Guan
2015-10-19 13:56   ` David Sterba
2015-10-19 11:37 ` [PATCH 05/10] btrfs-progs: mute coverity warnings about deadcode Eryu Guan
2015-10-21 11:34   ` David Sterba
2015-10-19 11:37 ` [PATCH 06/10] btrfs-progs: vailidate pointer before dereferencing it in btrfs_cow_block() Eryu Guan
2015-10-19 13:47   ` David Sterba
2015-10-19 11:37 ` [PATCH 07/10] btrfs-progs: fix memory leak on error path Eryu Guan
2015-10-19 11:37 ` [PATCH 08/10] btrfs-progs: remove identical branch in record_extent() Eryu Guan
2015-10-19 11:37 ` [PATCH 09/10] btrfs-progs: fix memory leak in cmd_qgroup_show() Eryu Guan
2015-10-19 11:38 ` [PATCH 10/10] btrfs-progs: return -ENOMEM properly in btrfs_read_block_groups() Eryu Guan
2015-10-19 14:21 ` [PATCH 01/10] btrfs-progs: fix leak of "path" in btrfs_find_item() error paths David Sterba

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.