Merge branch 'i2c/for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa...
[firefly-linux-kernel-4.4.55.git] / fs / nilfs2 / dat.c
index fa0f80308c2dce70d89bf6e459119c9b18543d27..0d5fada9119136e793b73cf9d008bae29e43fcf8 100644 (file)
@@ -484,6 +484,18 @@ int nilfs_dat_read(struct super_block *sb, size_t entry_size,
        struct nilfs_dat_info *di;
        int err;
 
+       if (entry_size > sb->s_blocksize) {
+               printk(KERN_ERR
+                      "NILFS: too large DAT entry size: %zu bytes.\n",
+                      entry_size);
+               return -EINVAL;
+       } else if (entry_size < NILFS_MIN_DAT_ENTRY_SIZE) {
+               printk(KERN_ERR
+                      "NILFS: too small DAT entry size: %zu bytes.\n",
+                      entry_size);
+               return -EINVAL;
+       }
+
        dat = nilfs_iget_locked(sb, NULL, NILFS_DAT_INO);
        if (unlikely(!dat))
                return -ENOMEM;