Skip to content

Commit 22883dd

Browse files
Lu Fengqikdave
authored andcommitted
btrfs: fix invalid-free in btrfs_extent_same
If this condition ((BTRFS_I(src)->flags & BTRFS_INODE_NODATASUM) != (BTRFS_I(dst)->flags & BTRFS_INODE_NODATASUM)) is hit, we will go to free the uninitialized cmp.src_pages and cmp.dst_pages. Fixes: 67b07bd ("Btrfs: reuse cmp workspace in EXTENT_SAME ioctl") Signed-off-by: Lu Fengqi <[email protected]> Reviewed-by: David Sterba <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent f098631 commit 22883dd

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

fs/btrfs/ioctl.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3577,7 +3577,7 @@ static int btrfs_extent_same(struct inode *src, u64 loff, u64 olen,
35773577
ret = btrfs_extent_same_range(src, loff, BTRFS_MAX_DEDUPE_LEN,
35783578
dst, dst_loff, &cmp);
35793579
if (ret)
3580-
goto out_unlock;
3580+
goto out_free;
35813581

35823582
loff += BTRFS_MAX_DEDUPE_LEN;
35833583
dst_loff += BTRFS_MAX_DEDUPE_LEN;
@@ -3587,16 +3587,16 @@ static int btrfs_extent_same(struct inode *src, u64 loff, u64 olen,
35873587
ret = btrfs_extent_same_range(src, loff, tail_len, dst,
35883588
dst_loff, &cmp);
35893589

3590+
out_free:
3591+
kvfree(cmp.src_pages);
3592+
kvfree(cmp.dst_pages);
3593+
35903594
out_unlock:
35913595
if (same_inode)
35923596
inode_unlock(src);
35933597
else
35943598
btrfs_double_inode_unlock(src, dst);
35953599

3596-
out_free:
3597-
kvfree(cmp.src_pages);
3598-
kvfree(cmp.dst_pages);
3599-
36003600
return ret;
36013601
}
36023602

0 commit comments

Comments
 (0)