Merge branch 'topic/enum-info-cleanup' into for-next
[firefly-linux-kernel-4.4.55.git] / fs / omfs / inode.c
index ba8819702c56719ae8a1a7b4596662a653a6ef0b..138321b0c6c2b95a8efcef1a5b3183f3126acbb9 100644 (file)
@@ -306,9 +306,7 @@ static const struct super_operations omfs_sops = {
  */
 static int omfs_get_imap(struct super_block *sb)
 {
-       int bitmap_size;
-       int array_size;
-       int count;
+       unsigned int bitmap_size, count, array_size;
        struct omfs_sb_info *sbi = OMFS_SB(sb);
        struct buffer_head *bh;
        unsigned long **ptr;
@@ -473,6 +471,12 @@ static int omfs_fill_super(struct super_block *sb, void *data, int silent)
        sbi->s_sys_blocksize = be32_to_cpu(omfs_sb->s_sys_blocksize);
        mutex_init(&sbi->s_bitmap_lock);
 
+       if (sbi->s_num_blocks > OMFS_MAX_BLOCKS) {
+               printk(KERN_ERR "omfs: sysblock number (%llx) is out of range\n",
+                      (unsigned long long)sbi->s_num_blocks);
+               goto out_brelse_bh;
+       }
+
        if (sbi->s_sys_blocksize > PAGE_SIZE) {
                printk(KERN_ERR "omfs: sysblock size (%d) is out of range\n",
                        sbi->s_sys_blocksize);