Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

btrfs: fix invalid leaf access in btrfs_quota_enable() if ref key not found

If btrfs_search_slot_for_read() returns 1, it means we did not find any
key greater than or equals to the key we asked for, meaning we have
reached the end of the tree and therefore the path is not valid. If
this happens we need to break out of the loop and stop, instead of
continuing and accessing an invalid path.

Fixes: 5223cc60b40a ("btrfs: drop the path before adding qgroup items when enabling qgroups")
Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>

authored by

Filipe Manana and committed by
David Sterba
ecb7c248 7b54e08f

+7 -4
+7 -4
fs/btrfs/qgroup.c
··· 1169 1169 } 1170 1170 if (ret > 0) { 1171 1171 /* 1172 - * Shouldn't happen, but in case it does we 1173 - * don't need to do the btrfs_next_item, just 1174 - * continue. 1172 + * Shouldn't happen because the key should still 1173 + * be there (return 0), but in case it does it 1174 + * means we have reached the end of the tree - 1175 + * there are no more leaves with items that have 1176 + * a key greater than or equals to @found_key, 1177 + * so just stop the search loop. 1175 1178 */ 1176 - continue; 1179 + break; 1177 1180 } 1178 1181 } 1179 1182 ret = btrfs_next_item(tree_root, path);