]> asedeno.scripts.mit.edu Git - linux.git/blobdiff - fs/ext2/balloc.c
Merge tag 'kvmarm-fixes-5.4-1' of git://git.kernel.org/pub/scm/linux/kernel/git/kvmar...
[linux.git] / fs / ext2 / balloc.c
index 547c165299c0c5a209cd6f5f45d2e31e5e3f364e..e0cc551645059d1bd98a5b622563afae2381448e 100644 (file)
@@ -490,9 +490,7 @@ void ext2_free_blocks (struct inode * inode, unsigned long block,
        struct ext2_super_block * es = sbi->s_es;
        unsigned freed = 0, group_freed;
 
-       if (block < le32_to_cpu(es->s_first_data_block) ||
-           block + count < block ||
-           block + count > le32_to_cpu(es->s_blocks_count)) {
+       if (!ext2_data_block_valid(sbi, block, count)) {
                ext2_error (sb, "ext2_free_blocks",
                            "Freeing blocks not in datazone - "
                            "block = %lu, count = %lu", block, count);
@@ -1203,13 +1201,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;