Skip to content

Commit a05a9bb

Browse files
Li Zefankdave
authored andcommitted
Btrfs: fix array bound checking
Otherwise we can execced the array bound of path->slots[]. Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
1 parent f4c697e commit a05a9bb

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

‎fs/btrfs/ctree.c‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -902,9 +902,10 @@ static noinline int balance_level(struct btrfs_trans_handle *trans,
902902

903903
orig_ptr = btrfs_node_blockptr(mid, orig_slot);
904904

905-
if (level < BTRFS_MAX_LEVEL - 1)
905+
if (level < BTRFS_MAX_LEVEL - 1) {
906906
parent = path->nodes[level + 1];
907-
pslot = path->slots[level + 1];
907+
pslot = path->slots[level + 1];
908+
}
908909

909910
/*
910911
* 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,
11071108
mid = path->nodes[level];
11081109
WARN_ON(btrfs_header_generation(mid) != trans->transid);
11091110

1110-
if (level < BTRFS_MAX_LEVEL - 1)
1111+
if (level < BTRFS_MAX_LEVEL - 1) {
11111112
parent = path->nodes[level + 1];
1112-
pslot = path->slots[level + 1];
1113+
pslot = path->slots[level + 1];
1114+
}
11131115

11141116
if (!parent)
11151117
return 1;

0 commit comments

Comments
 (0)