]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
btrfs: fix invalid leaf access in btrfs_quota_enable() if ref key not found
authorFilipe Manana <fdmanana@suse.com>
Wed, 4 Feb 2026 17:15:53 +0000 (17:15 +0000)
committerDavid Sterba <dsterba@suse.com>
Wed, 18 Feb 2026 14:25:54 +0000 (15:25 +0100)
commitecb7c2484cfc83a93658907580035a8adf1e0a92
tree21f6566dc3b1975989f558ff329ceecc5e76e7ed
parent7b54e08f2ef8f94d7e3959dde3694c4c34fa7701
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>
fs/btrfs/qgroup.c