Skip to content

Commit 80c0b42

Browse files
liubogithubkdave
authored andcommitted
Btrfs: fix NULL pointer dereference in log_dir_items
0, 1 and <0 can be returned by btrfs_next_leaf(), and when <0 is returned, path->nodes[0] could be NULL, log_dir_items lacks such a check for <0 and we may run into a null pointer dereference panic. Fixes: e02119d ("Btrfs: Add a write ahead tree log to optimize synchronous operations") Reviewed-by: Nikolay Borisov <[email protected]> Signed-off-by: Liu Bo <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent 57599c7 commit 80c0b42

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

fs/btrfs/tree-log.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3520,8 +3520,11 @@ static noinline int log_dir_items(struct btrfs_trans_handle *trans,
35203520
* from this directory and from this transaction
35213521
*/
35223522
ret = btrfs_next_leaf(root, path);
3523-
if (ret == 1) {
3524-
last_offset = (u64)-1;
3523+
if (ret) {
3524+
if (ret == 1)
3525+
last_offset = (u64)-1;
3526+
else
3527+
err = ret;
35253528
goto done;
35263529
}
35273530
btrfs_item_key_to_cpu(path->nodes[0], &tmp, path->slots[0]);

0 commit comments

Comments
 (0)