summaryrefslogtreecommitdiffstats
path: root/fs/ext2/balloc.c
diff options
context:
space:
mode:
authorChengguang Xu <cgxu519@zoho.com.cn>2019-07-23 19:21:54 +0800
committerJan Kara <jack@suse.cz>2019-07-31 12:04:42 +0200
commite5d395974e043cdcedcd84a0d41aaebb723786d8 (patch)
tree8ff04266c012c2ac4a3449149a9da23e3d489952 /fs/ext2/balloc.c
parent6fbacb8539a6659d446a9efabb538cfc007c1427 (diff)
downloadlinux-e5d395974e043cdcedcd84a0d41aaebb723786d8.tar.bz2
ext2: fix block range in ext2_data_block_valid()
For block validity we should check the block range from start_block to start_block + count - 1, so fix the range in ext2_data_block_valid() and also modify the count argument properly in calling place. Signed-off-by: Chengguang Xu <cgxu519@zoho.com.cn> Link: https://lore.kernel.org/r/20190723112155.20329-1-cgxu519@zoho.com.cn Signed-off-by: Jan Kara <jack@suse.cz>
Diffstat (limited to 'fs/ext2/balloc.c')
-rw-r--r--fs/ext2/balloc.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/fs/ext2/balloc.c b/fs/ext2/balloc.c
index 547c165299c0..92e9a7489174 100644
--- a/fs/ext2/balloc.c
+++ b/fs/ext2/balloc.c
@@ -1203,13 +1203,13 @@ int ext2_data_block_valid(struct ext2_sb_info *sbi, ext2_fsblk_t start_blk,
unsigned int count)
{
if ((start_blk <= le32_to_cpu(sbi->s_es->s_first_data_block)) ||
- (start_blk + count < start_blk) ||
- (start_blk > le32_to_cpu(sbi->s_es->s_blocks_count)))
+ (start_blk + count - 1 < start_blk) ||
+ (start_blk + count - 1 >= le32_to_cpu(sbi->s_es->s_blocks_count)))
return 0;
/* Ensure we do not step over superblock */
if ((start_blk <= sbi->s_sb_block) &&
- (start_blk + count >= sbi->s_sb_block))
+ (start_blk + count - 1 >= sbi->s_sb_block))
return 0;
return 1;