aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/tree-log.c
diff options
context:
space:
mode:
authorDavid Sterba <dsterba@suse.cz>2015-01-02 12:45:16 -0500
committerDavid Sterba <dsterba@suse.cz>2015-01-14 13:23:46 -0500
commit381cf6587f8a8a8e981bc0c1aaaa8859b51dc756 (patch)
tree024b49bf7f036ff79846076c44710337bd0d5ec1 /fs/btrfs/tree-log.c
parenteaa27f34e91a14cdceed26ed6c6793ec1d186115 (diff)
btrfs: fix leak of path in btrfs_find_item
If btrfs_find_item is called with NULL path it allocates one locally but does not free it. Affected paths are inserting an orphan item for a file and for a subvol root. Move the path allocation to the callers. CC: <stable@vger.kernel.org> # 3.14+ Fixes: 3f870c289900 ("btrfs: expand btrfs_find_item() to include find_orphan_item functionality") Signed-off-by: David Sterba <dsterba@suse.cz>
Diffstat (limited to 'fs/btrfs/tree-log.c')
-rw-r--r--fs/btrfs/tree-log.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c
index 9a02da16f2be..5be45c12dd71 100644
--- a/fs/btrfs/tree-log.c
+++ b/fs/btrfs/tree-log.c
@@ -1257,10 +1257,19 @@ static int insert_orphan_item(struct btrfs_trans_handle *trans,
1257 struct btrfs_root *root, u64 offset) 1257 struct btrfs_root *root, u64 offset)
1258{ 1258{
1259 int ret; 1259 int ret;
1260 ret = btrfs_find_item(root, NULL, BTRFS_ORPHAN_OBJECTID, 1260 struct btrfs_path *path;
1261
1262 path = btrfs_alloc_path();
1263 if (!path)
1264 return -ENOMEM;
1265
1266 ret = btrfs_find_item(root, path, BTRFS_ORPHAN_OBJECTID,
1261 offset, BTRFS_ORPHAN_ITEM_KEY, NULL); 1267 offset, BTRFS_ORPHAN_ITEM_KEY, NULL);
1262 if (ret > 0) 1268 if (ret > 0)
1263 ret = btrfs_insert_orphan_item(trans, root, offset); 1269 ret = btrfs_insert_orphan_item(trans, root, offset);
1270
1271 btrfs_free_path(path);
1272
1264 return ret; 1273 return ret;
1265} 1274}
1266 1275