Btrfs-progs: add missing path alloc return value check
authorFilipe David Borba Manana <fdmanana@gmail.com>
Tue, 30 Jul 2013 11:09:55 +0000 (12:09 +0100)
committerDavid Sterba <dsterba@suse.cz>
Fri, 9 Aug 2013 12:32:37 +0000 (14:32 +0200)
Also remove unused path in extent-tree.c:finish_current_insert().

Signed-off-by: Filipe David Borba Manana <fdmanana@gmail.com>
Reviewed-by: Miao Xie <miaox@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
btrfs-corrupt-block.c
cmds-check.c
dir-item.c
extent-tree.c
file-item.c
root-tree.c

index 481b7b8..4478f23 100644 (file)
@@ -163,6 +163,8 @@ static int corrupt_extent(struct btrfs_trans_handle *trans,
        int should_del = rand() % 3;
 
        path = btrfs_alloc_path();
+       if (!path)
+               return -ENOMEM;
 
        key.objectid = bytenr;
        key.type = (u8)-1;
index 5349d4b..3f913ce 100644 (file)
@@ -4569,6 +4569,8 @@ static int fixup_extent_refs(struct btrfs_trans_handle *trans,
                flags = BTRFS_BLOCK_FLAG_FULL_BACKREF;
 
        path = btrfs_alloc_path();
+       if (!path)
+               return -ENOMEM;
 
        /* step one, make sure all of the backrefs agree */
        ret = verify_backrefs(trans, info, path, rec);
index f00485a..0ab3c5e 100644 (file)
@@ -123,6 +123,8 @@ int btrfs_insert_dir_item(struct btrfs_trans_handle *trans, struct btrfs_root
        btrfs_set_key_type(&key, BTRFS_DIR_ITEM_KEY);
        key.offset = btrfs_name_hash(name, name_len);
        path = btrfs_alloc_path();
+       if (!path)
+               return -ENOMEM;
        data_size = sizeof(*dir_item) + name_len;
        dir_item = insert_with_overflow(trans, root, path, &key, data_size,
                                        name, name_len);
index 9f1ca60..35fd82e 100644 (file)
@@ -1483,6 +1483,8 @@ int btrfs_lookup_extent_info(struct btrfs_trans_handle *trans,
        }
 
        path = btrfs_alloc_path();
+       if (!path)
+               return -ENOMEM;
        path->reada = 1;
 
        key.objectid = bytenr;
@@ -1574,6 +1576,8 @@ int btrfs_set_block_flags(struct btrfs_trans_handle *trans,
                                  BTRFS_FEATURE_INCOMPAT_SKINNY_METADATA);
 
        path = btrfs_alloc_path();
+       if (!path)
+               return -ENOMEM;
        path->reada = 1;
 
        key.objectid = bytenr;
@@ -2075,7 +2079,6 @@ static int finish_current_insert(struct btrfs_trans_handle *trans,
        u64 end;
        u64 priv;
        struct btrfs_fs_info *info = extent_root->fs_info;
-       struct btrfs_path *path;
        struct pending_extent_op *extent_op;
        struct btrfs_key key;
        int ret;
@@ -2083,8 +2086,6 @@ static int finish_current_insert(struct btrfs_trans_handle *trans,
                btrfs_fs_incompat(extent_root->fs_info,
                                  BTRFS_FEATURE_INCOMPAT_SKINNY_METADATA);
 
-       path = btrfs_alloc_path();
-
        while(1) {
                ret = find_first_extent_bit(&info->extent_ins, 0, &start,
                                            &end, EXTENT_LOCKED);
@@ -2119,7 +2120,6 @@ static int finish_current_insert(struct btrfs_trans_handle *trans,
                                  GFP_NOFS);
                kfree(extent_op);
        }
-       btrfs_free_path(path);
        return 0;
 }
 
index 9c787f0..82bf99e 100644 (file)
@@ -417,6 +417,8 @@ int btrfs_del_csums(struct btrfs_trans_handle *trans,
        root = root->fs_info->csum_root;
 
        path = btrfs_alloc_path();
+       if (!path)
+               return -ENOMEM;
 
        while (1) {
                key.objectid = BTRFS_EXTENT_CSUM_OBJECTID;
index c6b13dc..09873a4 100644 (file)
@@ -193,6 +193,8 @@ int btrfs_add_root_ref(struct btrfs_trans_handle *trans,
 
 
        path = btrfs_alloc_path();
+       if (!path)
+               return -ENOMEM;
 
        key.objectid = root_id;
        key.type = type;