summaryrefslogtreecommitdiffstats
path: root/fs/btrfs/ctree.c
diff options
context:
space:
mode:
authorChris Mason <clm@fb.com>2015-01-21 17:45:25 -0800
committerChris Mason <clm@fb.com>2015-01-21 17:45:25 -0800
commitd3541834884f042aaaab1d6c0610cdc3488028e4 (patch)
treed6f8f0ac6c98b1f996dfcaae5df0ba33a6fa5251 /fs/btrfs/ctree.c
parentce93ec548cfa02f9cd6b70d546d5f36f4d160f57 (diff)
parent1d4c08e0a60be356134d0c466744d0d4e16ebab0 (diff)
downloadlinux-0-day-d3541834884f042aaaab1d6c0610cdc3488028e4.tar.gz
linux-0-day-d3541834884f042aaaab1d6c0610cdc3488028e4.tar.xz
Merge branch 'fix/find-item-path-leak' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux into for-linus
Diffstat (limited to 'fs/btrfs/ctree.c')
-rw-r--r--fs/btrfs/ctree.c18
1 files changed, 5 insertions, 13 deletions
diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
index 97a98fc07cfcb..f64471e95e331 100644
--- a/fs/btrfs/ctree.c
+++ b/fs/btrfs/ctree.c
@@ -2617,32 +2617,24 @@ static int key_search(struct extent_buffer *b, struct btrfs_key *key,
return 0;
}
-int btrfs_find_item(struct btrfs_root *fs_root, struct btrfs_path *found_path,
+int btrfs_find_item(struct btrfs_root *fs_root, struct btrfs_path *path,
u64 iobjectid, u64 ioff, u8 key_type,
struct btrfs_key *found_key)
{
int ret;
struct btrfs_key key;
struct extent_buffer *eb;
- struct btrfs_path *path;
+
+ ASSERT(path);
+ ASSERT(found_key);
key.type = key_type;
key.objectid = iobjectid;
key.offset = ioff;
- if (found_path == NULL) {
- path = btrfs_alloc_path();
- if (!path)
- return -ENOMEM;
- } else
- 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);
+ if (ret < 0)
return ret;
- }
eb = path->nodes[0];
if (ret && path->slots[0] >= btrfs_header_nritems(eb)) {