diff --git a/fs/btrfs/file-item.c b/fs/btrfs/file-item.c index 763fd170ff1656fedce3dd37fc68a492d7c8f711..b5baf5bdc8e183df9fd697eda5a7d2d16b97baa0 100644 --- a/fs/btrfs/file-item.c +++ b/fs/btrfs/file-item.c @@ -292,12 +292,22 @@ static int __btrfs_lookup_bio_sums(struct btrfs_root *root, page_bytes_left -= root->sectorsize; if (!page_bytes_left) { bio_index++; + /* + * make sure we're still inside the + * bio before we update page_bytes_left + */ + if (bio_index >= bio->bi_vcnt) { + WARN_ON_ONCE(count); + goto done; + } bvec++; page_bytes_left = bvec->bv_len; } } } + +done: btrfs_free_path(path); return 0; }