]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
Btrfs: fix array bound checking
authorLi Zefan <lizf@cn.fujitsu.com>
Tue, 6 Sep 2011 08:55:34 +0000 (16:55 +0800)
committerDavid Sterba <dsterba@suse.cz>
Thu, 20 Oct 2011 16:10:41 +0000 (18:10 +0200)
Otherwise we can execced the array bound of path->slots[].

Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
fs/btrfs/ctree.c

index 011cab3aca8d9ffeba2690f642badec7e36471c9..0fe615e4ea387582acc06f60cac81366f23fe069 100644 (file)
@@ -902,9 +902,10 @@ static noinline int balance_level(struct btrfs_trans_handle *trans,
 
        orig_ptr = btrfs_node_blockptr(mid, orig_slot);
 
-       if (level < BTRFS_MAX_LEVEL - 1)
+       if (level < BTRFS_MAX_LEVEL - 1) {
                parent = path->nodes[level + 1];
-       pslot = path->slots[level + 1];
+               pslot = path->slots[level + 1];
+       }
 
        /*
         * deal with the case where there is only one pointer in the root
@@ -1107,9 +1108,10 @@ static noinline int push_nodes_for_insert(struct btrfs_trans_handle *trans,
        mid = path->nodes[level];
        WARN_ON(btrfs_header_generation(mid) != trans->transid);
 
-       if (level < BTRFS_MAX_LEVEL - 1)
+       if (level < BTRFS_MAX_LEVEL - 1) {
                parent = path->nodes[level + 1];
-       pslot = path->slots[level + 1];
+               pslot = path->slots[level + 1];
+       }
 
        if (!parent)
                return 1;