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: replace ASSERT with proper error handling in stripe lookup fallback

After falling back to the previous item in btrfs_delete_raid_extent(),
the code uses ASSERT(found_start <= start) to verify the found extent
actually precedes our target range. If the B-tree state is unexpected
(e.g. no overlapping extent exists), this triggers a kernel BUG/panic
in debug builds, or silently continues with wrong data otherwise.

Replace the ASSERT with a proper bounds check that returns -ENOENT if
the found extent does not actually overlap with the start position.

Signed-off-by: robbieko <robbieko@synology.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>

authored by

robbieko and committed by
David Sterba
65336158 1871ae78

+4 -1
+4 -1
fs/btrfs/raid-stripe-tree.c
··· 154 154 btrfs_item_key_to_cpu(leaf, &key, slot); 155 155 found_start = key.objectid; 156 156 found_end = found_start + key.offset; 157 - ASSERT(found_start <= start); 157 + if (found_start > start || found_end <= start) { 158 + ret = -ENOENT; 159 + break; 160 + } 158 161 } 159 162 160 163 if (key.type != BTRFS_RAID_STRIPE_KEY)