Skip to content

Commit 3736127

Browse files
marcospskdave
authored andcommitted
btrfs: tree-log: check btrfs_lookup_data_extent return value
Function btrfs_lookup_data_extent calls btrfs_search_slot to verify if the EXTENT_ITEM exists in the extent tree. btrfs_search_slot can return values bellow zero if an error happened. Function replay_one_extent currently checks if the search found something (0 returned) and increments the reference, and if not, it seems to evaluate as 'not found'. Fix the condition by checking if the value was bellow zero and return early. Reviewed-by: Filipe Manana <[email protected]> Signed-off-by: Marcos Paulo de Souza <[email protected]> Reviewed-by: David Sterba <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent 8be2ba2 commit 3736127

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

fs/btrfs/tree-log.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -753,7 +753,9 @@ static noinline int replay_one_extent(struct btrfs_trans_handle *trans,
753753
*/
754754
ret = btrfs_lookup_data_extent(fs_info, ins.objectid,
755755
ins.offset);
756-
if (ret == 0) {
756+
if (ret < 0) {
757+
goto out;
758+
} else if (ret == 0) {
757759
btrfs_init_generic_ref(&ref,
758760
BTRFS_ADD_DELAYED_REF,
759761
ins.objectid, ins.offset, 0);

0 commit comments

Comments
 (0)