Commit 1a77e409 authored by Filipe Manana's avatar Filipe Manana Committed by Yifan Qiao
Browse files

btrfs: remove superfluous metadata check at btrfs_lookup_extent_info()

mainline inclusion
from mainline-v6.11-rc1
commit c65967ac4d1668dfcb903215c8af128fa15f05d6
bugzilla: https://gitee.com/src-openeuler/kernel/issues/IARX0N
CVE: CVE-2024-46751

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=c65967ac4d1668dfcb903215c8af128fa15f05d6



--------------------------------

If we didn't found an extent item with the initial btrfs_search_slot()
call, it's pointless to test if the "metadata" variable is "true", because
right after we check if the key type is BTRFS_METADATA_ITEM_KEY and that
is the case only when "metadata" is set to "true". So remove the redundant
check.

Reviewed-by: default avatarQu Wenruo <wqu@suse.com>
Signed-off-by: default avatarFilipe Manana <fdmanana@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
Signed-off-by: default avatarYifan Qiao <qiaoyifan4@huawei.com>
parent 6f4a2726
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -155,7 +155,7 @@ int btrfs_lookup_extent_info(struct btrfs_trans_handle *trans,
	if (ret < 0)
		goto out_free;

	if (ret > 0 && metadata && key.type == BTRFS_METADATA_ITEM_KEY) {
	if (ret > 0 && key.type == BTRFS_METADATA_ITEM_KEY) {
		if (path->slots[0]) {
			path->slots[0]--;
			btrfs_item_key_to_cpu(path->nodes[0], &key,